Part Number Hot Search : 
IC18F IC18F SMB30C HV991106 0150C G62FP LB121 2002D
Product Description
Full Text Search
 

To Download HD6437021TE Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  superh risc engine sh7020 and sh7021 hd6437020, hd6477021, hd6437021, hd6417021 hardware manual ade-602-074b rev. 3.0 11/25/99 hitachi, ltd.

cautions 1. hitachi neither warrants nor grants licenses of any rights of hitachi? or any third party? patent, copyright, trademark, or other intellectual property rights for information contained in this document. hitachi bears no responsibility for problems that may arise with third party? rights, including intellectual property rights, in connection with use of the information contained in this document. 2. products and product specifications may be subject to change without notice. confirm that you have received the latest product standards or specifications before final design, purchase or use. 3. hitachi makes every attempt to ensure that its products are of high quality and reliability. however, contact hitachi? sales office before using the product in an application that demands especially high quality and reliability or where its failure or malfunction may directly threaten human life or cause risk of bodily injury, such as aerospace, aeronautics, nuclear power, combustion control, transportation, traffic, safety equipment or medical equipment for life support. 4. design your application so that the product is used within the ranges guaranteed by hitachi particularly for maximum rating, operating supply voltage range, heat radiation characteristics, installation conditions and other characteristics. hitachi bears no responsibility for failure or damage when used beyond the guaranteed ranges. even within the guaranteed ranges, consider normally foreseeable failure rates or failure modes in semiconductor devices and employ systemic measures such as fail-safes, so that the equipment incorporating hitachi product does not cause bodily injury, fire or other consequential damage due to operation of the hitachi product. 5. this product is not designed to be radiation resistant. 6. no one is permitted to reproduce or duplicate, in any form, the whole or part of this document without written approval from hitachi. 7. contact hitachi? sales office for any questions regarding this document or hitachi semiconductor products.
introduction the sh7020 and sh7021 are part of a new generation of reduced instruction-set computer-type (risc) microcomputers that integrate risc-type cpus and the peripheral functions required for system configuration onto a single chip to achieve high-performance operations processing. they can operate in a power-down state, which is an essential feature for portable equipment. the sh7020 and sh7021 cpus have risc-type instruction sets. basic instructions can be executed in a single clock cycle, which strikingly improves instruction execution speed. the sh7020 and sh7021 include peripheral functions such as large-capacity rom (prom or masked rom), ram, a direct memory access controller (dmac), timers, a serial communication interface (sci), an interrupt controller (intc), and i/o ports. these on-chip elements enable users to construct systems with the fewest possible components. external memory access support functions enable direct connection to sram and dram. without the use of glue logics. this hardware manual describes in detail the hardware functions of the sh7020 and sh7021. for information on the instructions, please refer to the programming manual. related manuals sh7000 series instructions "sh-1/sh-2/sh-dsp programming manual" for development support tools, contact your hitachi sales office.
organization of this manual table 1 describes how this manual is organized. figure 1 shows the relationships between the sections within this manual. table 1 manual organization category section title abbrevi- ation contents overview 1. overview features, internal block diagram, pin layout, pin functions cpu 2. cpu cpu register configuration, data structure. instruction features, instruction types, instruction lists operating modes 3. operating modes mcu mode, prom mode internal modules 4. exception processing resets, address errors, interrupts, trap instructions, illegal instructions 5. interrupt controller intc nmi interrupts, user break interrupts, irq interrupts, on-chip module interrupts 6. user break controller ubc break address and break bus cycles selection clock 7. clock pulse generator cpg crystal pulse generator, duty correction circuit buses 8. bus state controller bsc division of memory space, dram interface, refresh, wait state control, parity control 9. direct memory access controller dmac auto request, external request, on-chip peripheral module request, cycle steal mode, burst mode timers 10. 16-bit integrated- timer pulse unit itu waveform output mode, input capture function, counter clear function, buffer operation, pwm mode, complementary pwm mode, reset synchronized mode, synchronized operation, phase counting mode, compare match output mode 11. programmable timing pattern controller tpc compare match output triggers, non-overlap operation 12. watchdog timer wdt watchdog timer mode, interval timer mode data processing 13. serial communica- tion interface sci asynchronous mode, clock synchronous mode, multiprocessor communication function
table 1 manual organization (cont) category section title abbrevi- ation contents pins 14. pin function controller pfc pin function selection 15. parallel i/o ports i/o i/o port memory 16. rom rom on-chip rom 17. ram ram on-chip ram power-down states 18. power-down states sleep mode, standby mode electrical characteristics 19. electrical characteristics absolute maximum ratings, ac characteristics, dc characteristics, operation timing
4. exception processing 5. interrupt controller (intc) 6. user break controller (ubc) on-chip modules 7. clock pulse generator (cpg) 8. bus state controller (bc) 9. direct memory access controller (dmac) buses 10. 16-bit integrated-timer pulse unit (itu) timers 13. serial communication interface (sci) data processing 14. pin function controller (pfc) 15. parallel i/o ports pins 16. rom 17. ram memory 18. power-down states 19. electrical characteristics 1. overview 2. cpu 3. operating modes 11. programmable timing pattern controller (tpc) 12. watchdog timer (wdt) manual organization scheme
addresses of on-chip peripheral module registers the on-chip peripheral module registers are located in the on-chip peripheral module space (area 5: h'5000000?'5ffffff), but since the actual register space is only 512 bytes, address bits a23?9 are ignored. 32k shadow areas in 512 byte units that contain exactly the same contents as the actual registers are thus provided in the on-chip peripheral module space. in this manual, register addresses are specified as though the on-chip peripheral module registers were in the 512 bytes h'5fffe00?'5ffffff. only the values of the a27?24 and a8?0 bits are valid; the a23?9 bits are ignored. when h'5000000?'50001ff is accessed, for example, the result will be the same as when h'5fffe00?'5ffffff is accessed. for more details, see section 8.3.5, area description: area 5. free addresses in the on-chip peripheral module space (area 5) avoid reading/writing from/to the free addresses without registers in the on-chip peripheral module space (area 5: h'5000000-h'5ffffff).
contents section 1 overview .............................................................................................................. 1 1.1 sh microcomputer features.............................................................................................. 1 1.2 block diagram............................................................................................................... .... 7 1.3 pin descriptions............................................................................................................ ..... 8 1.3.1 pin arrangement .................................................................................................. 8 1.3.2 pin functions........................................................................................................ 9 1.3.3 pin layout by mode ............................................................................................. 13 section 2 cpu ....................................................................................................................... 15 2.1 register configuration ...................................................................................................... 15 2.1.1 general registers (rn) ......................................................................................... 15 2.1.2 control registers.................................................................................................. 15 2.1.3 system registers .................................................................................................. 16 2.1.4 initial values of registers .................................................................................... 17 2.2 data formats................................................................................................................ ...... 17 2.2.1 data format in registers...................................................................................... 17 2.2.2 data format in memory ....................................................................................... 18 2.2.3 immediate data format........................................................................................ 18 2.3 instruction features ..................................................................................................... ......... 19 2.3.1 risc-type instruction set ................................................................................... 19 2.3.2 addressing modes................................................................................................ 22 2.3.3 instruction formats .............................................................................................. 25 2.4 instruction set............................................................................................................. ....... 28 2.4.1 instruction set by classification .......................................................................... 28 2.4.2 operation code map ............................................................................................ 39 2.5 cpu state ................................................................................................................... ....... 41 2.5.1 state transitions ................................................................................................... 41 2.5.2 power-down state................................................................................................ 43 section 3 operating modes ............................................................................................... 45 3.1 types of operating modes and their selection................................................................ 45 3.2 operating mode descriptions............................................................................................ 45 3.2.1 mode 0 (mcu mode 0)........................................................................................ 45 3.2.2 mode 1 (mcu mode 1)........................................................................................ 45 3.2.3 mode 2 (mcu mode 2)........................................................................................ 45 3.2.4 mode 7 (prom mode) ........................................................................................ 45 section 4 exception processing ....................................................................................... 47 4.1 overview.................................................................................................................... ........ 47
4.1.1 exception processing types and priorities .......................................................... 47 4.1.2 exception processing operation .......................................................................... 49 4.1.3 exception process vector table .......................................................................... 49 4.2 reset ....................................................................................................................... ........... 51 4.2.1 reset types .......................................................................................................... 51 4.2.2 power-on reset.................................................................................................... 51 4.2.3 manual reset........................................................................................................ 52 4.3 address errors .............................................................................................................. ..... 52 4.3.1 address error sources.......................................................................................... 52 4.3.2 address error exception processing.................................................................... 53 4.4 interrupts.................................................................................................................. .......... 54 4.4.1 interrupt sources .................................................................................................. 54 4.4.2 interrupt priority rankings................................................................................... 54 4.4.3 interrupt exception processing ............................................................................ 55 4.5 instruction exceptions ...................................................................................................... .55 4.5.1 types of instruction exceptions........................................................................... 55 4.5.2 trap instruction .................................................................................................... 55 4.5.3 illegal slot instruction .......................................................................................... 56 4.5.4 general illegal instructions .................................................................................. 56 4.6 cases in which exceptions are not accepted ................................................................. 57 4.6.1 immediately after delayed branch instructions................................................... 57 4.6.2 immediately after interrupt-disabling instructions.............................................. 57 4.7 stack status after exception processing............................................................................ 58 4.8 notes....................................................................................................................... ........... 59 4.8.1 value of the stack pointer (sp)............................................................................ 59 4.8.2 value of the vector base register (vbr) ........................................................... 59 4.8.3 address errors that are caused by stacking during address error exception processing............................................................................................ 59 section 5 interrupt controller (intc) ........................................................................... 61 5.1 overview.................................................................................................................... ........ 61 5.1.1 features ................................................................................................................ 61 5.1.2 block diagram...................................................................................................... 61 5.1.3 pin configuration ................................................................................................. 63 5.1.4 registers ............................................................................................................... 63 5.2 interrupt sources........................................................................................................... ..... 63 5.2.1 nmi interrupts...................................................................................................... 64 5.2.2 user break interrupt ............................................................................................. 64 5.2.3 irq interrupts ...................................................................................................... 64 5.2.4 on-chip interrupts................................................................................................ 64 5.2.5 interrupt exception vectors and priority rankings ............................................. 65 5.3 register descriptions....................................................................................................... .. 68 5.3.1 interrupt priority registers a? (ipra?pre) ................................................... 68
5.3.2 interrupt control register (icr) .......................................................................... 69 5.4 interrupt operation ......................................................................................................... ... 70 5.4.1 interrupt sequence................................................................................................ 70 5.4.2 stack after interrupt exception processing .......................................................... 72 5.5 interrupt response time.................................................................................................... 7 3 5.5 usage notes ................................................................................................................. ...... 74 section 6 user break controller (ubc) ........................................................................ 75 6.1 overview.................................................................................................................... ........ 75 6.1.1 features ................................................................................................................ 75 6.1.2 block diagram...................................................................................................... 75 6.1.3 register configuration ......................................................................................... 76 6.2 register descriptions....................................................................................................... .. 77 6.2.1 break address registers (bar) .......................................................................... 77 6.2.2 break address mask register (bamr)............................................................... 78 6.2.3 break bus cycle register (bbr) ......................................................................... 79 6.3 operation ................................................................................................................... ........ 81 6.3.1 flow of the user break operation........................................................................ 81 6.3.2 break on instruction fetch cycles to on-chip memory...................................... 84 6.3.3 program counter (pc) value saved in user break interrupt exception processing............................................................................................................. 84 6.4 setting user break conditions .......................................................................................... 84 6.5 notes....................................................................................................................... ........... 86 6.5.1 on-chip memory instruction fetch ..................................................................... 86 6.5.2 instruction fetch at branches ............................................................................... 86 6.5.3 instruction fetch break ........................................................................................ 87 section 7 clock pulse generator (cpg) ....................................................................... 89 7.1 overview.................................................................................................................... ........ 89 7.2 clock source................................................................................................................ ...... 89 7.2.1 connecting a crystal resonator ........................................................................... 89 7.2.2 external clock input ............................................................................................ 90 7.3 usage notes ................................................................................................................. ...... 91 section 8 bus state controller (bsc) ............................................................................ 93 8.1 overview.................................................................................................................... ........ 93 8.1.1 features ................................................................................................................ 93 8.1.2 block diagram...................................................................................................... 93 8.1.3 pin configuration ................................................................................................. 95 8.1.4 register configuration ......................................................................................... 95 8.1.5 overview of areas................................................................................................ 96 8.2 register descriptions....................................................................................................... .. 97 8.2.1 bus control register (bcr) ................................................................................ 97
8.2.2 wait state control register 1 (wcr1)................................................................ 98 8.2.3 wait state control register 2 (wcr2)................................................................ 101 8.2.4 wait state control register 3 (wcr3)................................................................ 103 8.2.5 dram area control register (dcr).................................................................. 104 8.2.6 refresh control register (rcr) .......................................................................... 107 8.2.7 refresh timer control/status register (rtcsr) ................................................ 108 8.2.8 refresh timer counter (rtcnt) ........................................................................ 110 8.2.9 refresh time constant register (rtcor).......................................................... 112 8.2.10 parity control register (pcr).............................................................................. 112 8.2.11 notes on register access ..................................................................................... 114 8.3 address space subdivision................................................................................................ 115 8.3.1 address spaces and areas.................................................................................... 115 8.3.2 bus width............................................................................................................. 117 8.3.3 chip select signals ( cs0 cs7 )............................................................................ 117 8.3.4 shadows................................................................................................................ 118 8.3.5 area description .................................................................................................. 120 8.4 accessing external memory space ................................................................................... 128 8.4.1 basic timing ........................................................................................................ 128 8.4.2 wait state control ................................................................................................ 129 8.4.3 byte access control ............................................................................................. 133 8.5 dram interface operation ............................................................................................... 134 8.5.1 dram adress multiplexing ............................................................................... 134 8.5.2 basic timing ........................................................................................................ 136 8.5.3 wait state control ................................................................................................ 138 8.5.4 byte access control ............................................................................................. 140 8.5.5 dram burst mode .............................................................................................. 142 8.5.6 refresh control .................................................................................................... 148 8.6 address/data multiplexed i/o space access.................................................................... 151 8.6.1 basic timing ........................................................................................................ 152 8.6.2 wait state control ................................................................................................ 153 8.6.3 byte access control ............................................................................................. 153 8.7 parity check and generation ............................................................................................. 154 8.8 warp mode................................................................................................................... ..... 154 8.9 wait state control .......................................................................................................... ... 155 8.10 bus arbitration ............................................................................................................ ...... 157 8.10.1 the operation of bus arbitration ........................................................................ 158 8.10.2 back operation.................................................................................................. 159 8.11 usage notes ................................................................................................................ ....... 161 8.11.1 usage notes on manual reset.............................................................................. 161 8.11.2 usage notes on parity data pins dph and dpl ................................................. 164 8.11.3 maximum number of states from breq input to bus release ......................... 164 section 9 direct memory access controller (dmac) ............................................ 169
9.1 overview.................................................................................................................... ........ 169 9.1.1 features ................................................................................................................ 16 9 9.1.2 block diagram...................................................................................................... 170 9.1.3 pin configuration ................................................................................................. 172 9.1.4 register configuration ......................................................................................... 173 9.2 register descriptions....................................................................................................... .. 174 9.2.1 dma source address registers 0? (sar0?ar3) .......................................... 174 9.2.2 dma destination address registers 0-3 (dar0?ar3) .................................. 174 9.2.3 dma transfer count registers 0? (tcr0?cr3) ........................................... 175 9.2.4 dma channel control registers 0? (chcr0?hcr3)................................... 175 9.2.5 dma operation register (dmaor)................................................................... 180 9.3 operation ................................................................................................................... ........ 182 9.3.1 dma transfer flow ............................................................................................. 182 9.3.2 dma transfer requests....................................................................................... 184 9.3.3 channel priority.................................................................................................... 186 9.3.4 dma transfer types ........................................................................................... 191 9.3.5 number of bus cycle states and dreq pin sample timing.............................. 198 9.3.6 dma transfer ending conditions ....................................................................... 205 9.4 examples of use............................................................................................................. ... 206 9.4.1 dma transfer between on-chip ram and a memory-mapped external device .................................................................................................... 206 9.4.2 example of dma transfer between on-chip sci and external memory.......... 207 9.5 cautions .................................................................................................................... ......... 208 section 10 16-bit integrated-timer pulse unit (itu) .............................................. 213 10.1 overview................................................................................................................... ......... 213 10.1.1 features ................................................................................................................ 2 13 10.1.2 block diagram...................................................................................................... 216 10.1.3 input/output pins.................................................................................................. 221 10.1.4 register configuration ......................................................................................... 222 10.2 itu register descriptions ................................................................................................. 2 24 10.2.1 timer start register (tstr)................................................................................ 224 10.2.2 timer synchro register (tsnc).......................................................................... 226 10.2.3 timer mode register (tmdr) ............................................................................ 227 10.2.4 timer function control register (tfcr)............................................................ 230 10.2.5 timer output control register (tocr) .............................................................. 231 10.2.6 timer counters (tcnt)....................................................................................... 232 10.2.7 general registers a and b (gra and grb) ....................................................... 233 10.2.8 buffer registers a and b (bra, brb)................................................................ 234 10.2.9 timer control register (tcr) ............................................................................. 235 10.2.10 timer i/o control register (tior) ..................................................................... 237 10.2.11 timer status register (tsr) ................................................................................ 239 10.2.12 timer interrupt enable register (tier) .............................................................. 240
10.3 cpu interface .............................................................................................................. ...... 241 10.3.1 16-bit accessible registers.................................................................................. 241 10.3.2 8-bit accessible registers.................................................................................... 243 10.4 description of operation ................................................................................................... 244 10.4.1 overview .............................................................................................................. 244 10.4.2 basic functions .................................................................................................... 245 10.4.3 synchronizing mode ............................................................................................ 256 10.4.4 pwm mode .......................................................................................................... 258 10.4.5 reset-synchronized pwm mode ......................................................................... 262 10.4.6 complementary pwm mode................................................................................ 264 10.4.7 phase counting mode .......................................................................................... 272 10.4.8 buffer mode ......................................................................................................... 274 10.4.9 itu output timing .............................................................................................. 280 10.5 interrupts................................................................................................................. ........... 281 10.5.1 timing of setting status flags ............................................................................. 281 10.5.2 clear timing of status flags................................................................................ 283 10.5.3 interrupt sources and activating the dmac....................................................... 284 10.6 notes and precautions...................................................................................................... .. 285 10.6.1 contention between tcnt write and clear........................................................ 285 10.6.2 contention between tcnt word write and increment ...................................... 286 10.6.3 contention between tcnt byte write and increment........................................ 287 10.6.4 contention between gr write and compare match............................................ 288 10.6.5 contention between tcnt write and overflow/underflow ............................... 289 10.6.6 contention between general register read and input capture ........................... 290 10.6.7 contention between counter clearing by input capture and counter increment.............................................................................................................. 291 10.6.8 contention between general register write and input capture.......................... 292 10.6.9 note on waveform cycle setting ........................................................................ 292 10.6.10 contention between br write and input capture ............................................... 293 10.6.11 note on writing in the synchronizing mode ....................................................... 294 10.6.12 note on setting reset-synchronized pwm mode/complementary pwm mode .......................................................................................................... 294 10.6.13 clearing the complementary pwm mode........................................................... 295 10.6.14 itu operating modes .......................................................................................... 295 section 11 programmable timing pattern controller (tpc) .................................. 303 11.1 overview................................................................................................................... ......... 303 11.1.1 features ................................................................................................................ 3 03 11.1.2 block diagram...................................................................................................... 304 11.1.3 input/output pins.................................................................................................. 305 11.1.4 registers ............................................................................................................... 3 06 11.2 register descriptions...................................................................................................... ... 306 11.2.1 port b control registers 1 and 2 (pbcr1, pcbr2)............................................ 306
11.2.2 port b data register (pbdr)............................................................................... 307 11.2.3 next data register a (ndra) ............................................................................ 308 11.2.4 next data register b (ndrb) ............................................................................. 310 11.2.5 next data enable register a (ndera).............................................................. 311 11.2.6 next data enable register b (nderb) .............................................................. 312 11.2.7 tpc output control register (tpcr) ................................................................. 313 11.2.8 tpc output mode register (tpmr) ................................................................... 314 11.3 operation .................................................................................................................. ......... 316 11.3.1 overview .............................................................................................................. 316 11.3.2 output timing ...................................................................................................... 317 11.3.3 examples of use of ordinary tpc output .......................................................... 317 11.3.4 tpc output non-overlap operation.................................................................... 320 11.3.5 tpc output by input capture .............................................................................. 324 11.4 usage notes ................................................................................................................ ....... 325 11.4.1 non-overlap operation........................................................................................ 325 section 12 watchdog timer (wdt) .............................................................................. 327 12.1 overview................................................................................................................... ......... 327 12.1.1 features ................................................................................................................ 3 27 12.1.2 block diagram...................................................................................................... 328 12.1.3 pin configuration ................................................................................................. 328 12.1.4 register configuration ......................................................................................... 329 12.2 register descriptions...................................................................................................... ... 329 12.2.1 timer counter (tcnt) ........................................................................................ 329 12.2.2 timer control/status register (tcsr) ................................................................ 330 12.2.3 reset control/status register (rstcsr) ............................................................ 331 12.2.4 register access .................................................................................................... 333 12.3 operation .................................................................................................................. ......... 334 12.3.1 operation in the watchdog timer mode.............................................................. 334 12.3.2 operation in the interval timer mode.................................................................. 336 12.3.3 operation in the standby mode............................................................................ 336 12.3.4 timing of setting the overflow flag (ovf)........................................................ 337 12.3.5 timing of setting the watchdog timer overflow flag (wovf)........................ 337 12.4 usage notes ................................................................................................................ ....... 338 12.4.1 tcnt write and count up contention ............................................................... 338 12.4.2 changing cks2-cks0 bit values ...................................................................... 338 12.4.3 changing watchdog timer/interval timer modes .............................................. 338 12.4.4 system reset with wdtovf ............................................................................. 339 12.4.5 internal reset with the watchdog timer ............................................................ 339 section 13 serial communication interface (sci) .................................................... 341 13.1 overview................................................................................................................... ......... 341 13.1.1 features ................................................................................................................ 3 41
13.1.2 block diagram...................................................................................................... 342 13.1.3 input/output pins.................................................................................................. 343 13.1.4 register configuration ......................................................................................... 343 13.2 register descriptions...................................................................................................... ... 344 13.2.1 receive shift register .......................................................................................... 344 13.2.2 receive data register .......................................................................................... 344 13.2.3 transmit shift register ........................................................................................ 344 13.2.4 transmit data register......................................................................................... 345 13.2.5 serial mode register ............................................................................................ 345 13.2.6 serial control register ......................................................................................... 347 13.2.7 serial status register............................................................................................ 351 13.2.8 bit rate register (brr)....................................................................................... 355 13.3 operation .................................................................................................................. ......... 363 13.3.1 overview .............................................................................................................. 363 13.3.2 operation in asynchronous mode........................................................................ 366 13.3.3 multiprocessor communication ........................................................................... 376 13.3.4 clocked synchronous operation.......................................................................... 384 13.4 sci interrupt sources and the dmac............................................................................... 394 13.5 usage notes ................................................................................................................ ....... 394 section 14 pin function controller (pfc) .................................................................... 399 14.1 overview................................................................................................................... ......... 399 14.2 register configuration ..................................................................................................... . 401 14.3 register descriptions...................................................................................................... ... 401 14.3.1 port a i/o register (paior) ............................................................................... 401 14.3.2 port a control registers (pacr1 and pacr2) .................................................. 402 14.3.3 port b i/o register (pbior)................................................................................ 407 14.3.4 port b control registers (pbcr1 and pbcr2)................................................... 408 14.3.5 column address strobe pin control register (cascr) ..................................... 413 section 15 parallel i/o ports ............................................................................................. 415 15.1 overview................................................................................................................... ......... 415 15.2 port a..................................................................................................................... ............ 415 15.2.1 register configuration ......................................................................................... 415 15.2.2 port a data register (padr) .............................................................................. 416 15.3 port b ..................................................................................................................... ............ 417 15.3.1 register configuration ......................................................................................... 417 15.3.2 port b data register (pbdr)............................................................................... 418 section 16 rom ................................................................................................................... 419 16.1 overview................................................................................................................... ......... 419 16.2 prom mode.................................................................................................................. .... 421 16.2.1 setting the prom mode ...................................................................................... 421
16.2.2 socket adapter pin correspondence and memory map ..................................... 421 16. 3 prom programming ......................................................................................................... 4 23 16.3.1 selecting the programming mode........................................................................ 423 16.3.2 write/verify and electrical characteristics.......................................................... 424 16.3.3 points to note about writing............................................................................... 428 16.3.4 reliability after writing ...................................................................................... 429 section 17 ram ................................................................................................................... 431 17.1 overview................................................................................................................... ......... 431 17.2 operation .................................................................................................................. ......... 431 section 18 power-down states ........................................................................................ 433 18.1 overview................................................................................................................... ......... 433 18.1.1 power-down modes............................................................................................. 433 18.1.2 register................................................................................................................. 434 18.2 standby control register (sbycr).................................................................................. 434 18.3 sleep mode................................................................................................................. ....... 435 18.3.1 transition to the sleep mode ............................................................................... 435 18.3.2 canceling the sleep mode.................................................................................... 435 18.4 s t andby mode ............................................................................................................. ....... 436 18.4.1 transition to the standby mode ........................................................................... 436 18.4.2 canceling the standby mode................................................................................ 438 18.4.3 standby mode application................................................................................... 439 section 19 electrical characteristics .............................................................................. 441 19.1 absolute maximum ratings.............................................................................................. 441 19.2 dc characteristics ......................................................................................................... .... 442 19.3 ac characteristics ......................................................................................................... .... 449 19.3.1 clock timing........................................................................................................ 449 19.3.2 control signal timing.......................................................................................... 451 19.3.3 bus timing ........................................................................................................... 454 19.3.4 dmac timing ..................................................................................................... 490 19.3.5 16-bit integrated timer pulse unit timing.......................................................... 491 19.3.6 programmable timing pattern controller and i/o port timing .......................... 493 19.3.7 watchdog timer timing ...................................................................................... 494 19.3.8 serial communications interface timing ............................................................ 495 19.3.9 ac characteristics measurement conditions ...................................................... 497 19.4 usage note ................................................................................................................. ....... 498 appendix a on-chip peripheral module registers .................................................. 499 a.1 list of registers........................................................................................................... ...... 499 a.2 register tables............................................................................................................. ....... 509 a.2.1 serial mode register (smr)................................................................................ 509
a.2.2 bit rate register (brr)....................................................................................... 510 a.2.3 serial control register (scr).............................................................................. 510 a.2.4 transmit data register (tdr) ............................................................................. 512 a.2.5 serial status register (ssr)................................................................................. 512 a.2.6 receive data register (rdr) .............................................................................. 514 a.2.7 timer start register (tstr)................................................................................ 515 a.2.8 timer synchronization register (tsnc)............................................................. 515 a.2.9 timer mode register (tmdr) ............................................................................ 517 a.2.10 timer function control register (tfcr)............................................................ 518 a.2.11 timer control registers 0? (tcr0?cr4) ....................................................... 519 a.2.12 timer i/o control registers 0? (tio0?io4)................................................... 520 a.2.13 timer interrupt enable registers 0? (tier0?ier4)....................................... 521 a.2.14 timer status registers 0? (tsr0?sr4) .......................................................... 522 a.2.15 timer counter 0? (tcnt0?cnt4)................................................................. 523 a.2.16 general registers a0? (gra0?ra4) ............................................................. 524 a.2.17 general registers b0? (grb0?rb4).............................................................. 525 a.2.18 buffer registers a3, a4 (bra3, bra4)............................................................. 526 a.2.19 buffer registers b3, b4 (brb3, brb4) ............................................................... 527 a.2.20 timer output control register (tocr) .............................................................. 528 a.2.21 dma source address registers 0? (sar0?ar3) .......................................... 529 a.2.22 dma destination address registers 0? (dar0?ar3).................................. 530 a.2.23 dma transfer count registers 0? (tcr0?cr3) ........................................... 531 a.2.24 dma channel control registers 0? (chcr0?hcr3)................................... 532 a.2.25 dma operation registers (dmaor) ................................................................. 535 a.2.26 interrupt priority setting register a (ipra)........................................................ 536 a.2.27 interrupt priority setting register b (iprb)........................................................ 537 a.2.28 interrupt priority setting register c (iprc)........................................................ 538 a.2.29 interrupt priority setting register d (iprd)........................................................ 539 a.2.30 interrupt priority setting register e (ipre) ........................................................ 540 a.2.31 interrupt control register (icr) .......................................................................... 541 a.2.32 break address register h (barh) ..................................................................... 542 a.2.33 break address register l (barl) ...................................................................... 543 a.2.34 break address mask register h (bamrh)........................................................ 544 a.2.35 break address mask register l (bamrl)......................................................... 545 a.2.36 break bus cycle register (bbr) ......................................................................... 546 a.2.37 bus control register (bcr) ................................................................................ 548 a.2.38 wait state control register 1 (wcr1)................................................................ 549 a.2.39 wait state control register 2 (wcr2)................................................................ 550 a.2.40 wait state control register 3 (wcr3)................................................................ 552 a.2.41 dram area control register (dcr).................................................................. 553 a.2.42 parity control register (pcr).............................................................................. 555 a.2.43 refresh control register (rcr) .......................................................................... 556 a.2.44 refresh timer control/status register (rstcr) ................................................ 557
a.2.45 refresh timer counter register (rtcnt).......................................................... 558 a.2.46 refresh timer constant register (rtcor) ........................................................ 559 a.2.47 timer control/status register (tcsr) ................................................................ 559 a.2.48 timer counter (tcnt) ........................................................................................ 561 a.2.49 reset control/status register (rstcsr) ............................................................ 561 a.2.50 standby control register (sbycr) .................................................................... 562 a.2.51 port a data register (padr) .............................................................................. 563 a.2.52 port b data register (pbdr)............................................................................... 564 a.2.53 port a i/o register (paior) ............................................................................... 565 a.2.54 port b data register (pbior) ............................................................................. 566 a.2.55 port a control register 1 (pacr1)..................................................................... 567 a.2.56 port a control register 2 (pacr2)..................................................................... 569 a.2.57 port b control register 1 (pbcr1) ..................................................................... 571 a.2.58 port b control register 2 (pbcr2) ..................................................................... 573 a.2.59 column address strobe pin control register (cascr) ..................................... 575 a.2.60 tpc output mode register (tpmr) ................................................................... 576 a.2.61 tpc output control register (tpcr) ................................................................. 577 a.2.62 next data enable register a (ndera).............................................................. 579 a.2.63 next data enable register b (nderb) .............................................................. 579 a.2.64 next data register a (ndra) (when the output triggers of tpc output groups 0 and 1 are the same) ................................................................................ 580 a.2.65 next data register a (ndra) (when the output triggers of tpc output groups 0 and 1 are the same) ................................................................................ 581 a.2.66 next data register a (ndra) (when the output triggers of tpc output groups 0 and 1 are different) ................................................................................ 581 a.2.67 next data register a (ndra) (when the output triggers of tpc output groups 0 and 1 are different) ................................................................................ 582 a.2.68 next data register b (ndrb) (when the output triggers of tpc output groups 2 and 3 are the same) ................................................................................ 582 a.2.69 next data register b (ndrb) (when the output triggers of tpc output groups 2 and 3 are the same) ................................................................................ 583 a.2.70 next data register b (ndrb) (when the output triggers of tpc output groups 2 and 3 are different) ................................................................................ 584 a.2.71 next data register b (ndrb) (when the output triggers of tpc output groups 2 and 3 are different) ................................................................................ 584 a.3 register status in reset and power-down states.............................................................. 585 appendix b pin states ........................................................................................................ 588 appendix c external dimensions ................................................................................... 594
hitachi 1 section 1 overview 1.1 superh microcomputer features the superh microcomputer (sh7000 series) is a new generation reduced instruction set computer (risc) in which a hitachi-original cpu and the peripheral functions required for system configuration are integrated onto a single chip. the cpu has a risc-type instruction set. most instructions can be executed in one clock cycle, which strikingly improves instruction execution speed. in addition, the cpu has a 32-bit internal architecture for enhanced data-processing ability. as a result, the cpu enables high-performance systems to be constructed with advanced functionality at low cost, even in applications such as realtime control that require very high speeds, an impossibility with conventional microcomputers. the sh microcomputer includes peripheral functions such as large-capacity rom, ram, a direct memory access controller (dmac), timers, a serial communication interface (sci), an interrupt controller (intc), and i/o ports. external memory access support functions enable direct connection to sram and dram. these features can drastically reduce system cost. for on-chip rom, masked rom or electrically programmable rom (prom) can be selected. the prom version can be programmed by users with a general-purpose eprom programmer. table 1.1 lists the features of the sh microcomputers (sh7020 and sh7021).
2 hitachi table 1.1 features of the sh7020 and sh7021 microcomputers feature description cpu original hitachi architecture 32-bit internal data paths general-register machine: sixteen 32-bit general registers three 32-bit control registers four 32-bit system registers risc-type instruction set: instruction length: 16-bit fixed length for improved code efficiency load-store architecture (basic arithmetic and logic operations are executed between registers) delayed unconditional branch instructions reduce pipeline disruption instruction set optimized for c language instruction execution time: one instruction/cycle (50 ns/instruction at 20-mhz operation) address space: 4 gbytes available on the architecture on-chip multiplier: multiplication operations (16 bits 16 bits ? 32 bits) executed in 1? cycles, and multiplication/accumulation operations (16 bits 16 bits + 42 bits ? 42 bits) executed in 2? cycles five-stage pipeline operating modes operating modes: on-chip romless mode on-chip rom mode processing states: power-on reset state manual reset state exception processing state program execution state power-down state bus-released state power-down states: sleep mode software standby mode
hitachi 3 table 1.1 features of the sh7020 and sh7021 microcomputers (cont) feature description interrupt controller (intc) nine external interrupt pins (nmi, irq0 irq7 ) thirty internal interrupt sources sixteen programmable priority levels user break controller (ubc) generates an interrupt when the cpu or dmac generates a bus cycle with specified conditions simplifies configuration of a self-debugger clock pulse generator (cpg) on-chip clock pulse generator (maximum operating frequency: 20 mhz): 20-mhz pulses can be generated from a 20-mhz crystal with a duty cycle correcting circuit bus state controller (bsc) supports external memory access: sixteen-bit external data bus address space divided into eight areas with the following preset features: bus size (8 or 16 bits) number of wait cycles can be defined by user. type of area (external memory area, dram area, etc.) simplifies connection to rom, sram, dram, and peripheral i/o when the dram area is accessed: ras and cas signals for dram are output tp cycles can be generated to assure ras precharge time address multiplexing is supported internally, so dram can be connected directly chip select signals ( cs0 to cs7 ) are output for each area dram refresh function: programmable refresh interval supports cas-before-ras refresh and self-refresh modes dram burst access function: supports high-speed access modes for dram wait cycles can be inserted by an external wait signal one-stage write buffer improves the system performance data bus parity can be generated and checked
4 hitachi table 1.1 features of the sh7032 and sh7034 microcomputers (cont) feature description direct memory access controller (dmac) (4 channels) permits dma transfer between the following modules: external memory external i/o on-chip memory peripheral on-chip modules (except dmac) dma transfer can be requested from external pins, on-chip sci, on- chip timers, and on-chip a/d converter cycle-steal mode or burst mode channel priority level is selectable channels 0 and 1: dual or single address transfer mode is selectable; external request sources are supported; channels 2 and 3: dual address transfer mode, internal request sources only 16-bit integrated-timer ten types of waveforms can be output pulse unit (itu) input pulse width and cycle can be measured pwm mode: pulse output with 0?00% duty cycle (maximum resolution: 50 ns) complementary pwm mode: can output a maximum of three pairs of non-overlapping pwm waveforms phase counting mode: can count up or down according to the phase of an external two-phase clock timing pattern controller maximum 16-bit output (4 bits 4 channels) can be output (tpc) non-overlap intervals can be established between pairs of waveforms timing-source timer is selectable watchdog timer (wdt) can be used as watchdog timer or interval timer (1 channel) timer overflow can generate an internal reset, external signal, or interrupt power-on reset or manual reset can be selected as the internal reset serial communication asynchronous or clocked synchronous mode is selectable interface (sci) (2 channels) can transmit and receive simultaneously (full duplex) on-chip baud rate generator in each channel multiprocessor communication function
hitachi 5 table 1.1 features of the sh7032 and sh7034 microcomputers (cont) feature description i/o ports total of 40 i/o lines (32 input/output lines, 8 input-only lines): port a: 16 input/output lines (input or output can be selected for each bit) port b: 16 input/output lines (input or output can be selected for each bit) on-chip memory sh7020: 16-kbyte masked rom, and 1-kbyte ram sh7021: 32-kbyte electrically programmable rom or masked rom, and 1-kbyte ram 32-bit data can be accessed in one clock cycle
6 hitachi table 1.2 product line product number on-chip rom operating voltage operating frequency operating temperature model marking model no. package sh7021 masked 5.0v 2 to 20mhz -20 to +75 c hd6437021x HD6437021TE 100-pin rom 2 to 16.6mhz -40 to +85 c hd6437021xi HD6437021TEi plastic tqfp 3.3v 2 to 12.5mhz -20 to +75 c hd6437021vx hd6437021vte (tfp-100b) -40 to +85 c hd6437021vxi hd6437021vtei prom 5.0v 2 to 20mhz -20 to +75 c hd6477021x hd6477021te 2 to 16.6mhz -40 to +85 c hd6477021xi hd6477021tei 3.3v 2 to 12.5mhz -20 to +75 c hd6477021vx hd6477021vte -40 to +85 c hd6477021vxi hd6477021vtei sh7020 masked 5.0v 2 to 20mhz -20 to +75 c hd6437020x hd6437020te rom 2 to 16.6mhz -40 to +85 c hd6437020xi hd6437020tei 3.3v 2 to 12.5mhz -20 to +75 c hd6437020vx hd6437020vte -40 to +85 c hd6437020vxi hd6437020vtei romless 5.0v 2 to 20mhz -40 to +85 c hd6417020sx20i hd6417020x20i 3.3v 2 to 12.5mhz -40 to +85 c hd6417020svx12i hd6417020vx12i
hitachi 7 1.2 block diagram a15 a14 a13 a12 a11 a10 a9 a8 a7 a6 a5 a4 a3 a2 a1 a0 ( hbs ) ad15 ad14 ad13 ad12 ad11 ad10 ad9 ad8 ad7 ad6 ad5 ad4 ad3 ad2 ad1 ad0 md2 md1 md0 nmi ck extal xtal v cc v cc v cc v cc v cc v cc v ss v ss v ss v ss v ss v ss v ss av ref av cc res (vpp)* wdtovf cs3 / casl cs2 cs1 / cash cs0 a21 a20 a19 a18 a17 a16 pa15/ irq3 / dreq1 pa14/ irq2 /dack1 pa13/ irq1 / dreq0 /tclkb pa12/ irq0 /dack0/tclka pa11/dph/tiocb1 pa10/dpl/tioca1 pa9/ ah / irqout / adtrg pa8/ breq pa7/ back pa6/ rd pa5/ wrh ( lbs ) pa4/ wrl ( wr ) pa3/ cs7 / wait pa2/ cs6 /tiocb0 pa1/ cs5 / ras pa0/ cs4 /tioca0 pb15/tp15/ irq7 pb14/tp14/ irq6 pb13/tp13/ irq5 /sck1 pb12/tp12/ irq4 /sck0 pb11/tp11/txd1 pb10/tp10/rxd1 pb9/tp9/txd0 pb8/tp8/rxd0 pb7/tp7/tocxb4/tclkd pb6/tp6/tocxa4/tclkc pb5/tp5/tiocb4 pb4/tp4/tioca4 pb3/tp3/tiocb3 pb2/tp2/tioca3 pb1/tp1/tiocb2 pb0/tp0/tioca2 : peripheral address bus (24 bits) : peripheral data bus (16 bits) : internal address bus (24 bits) : internal upper data bus (16 bits) : internal lower data bus (16 bits) port a address address data/address port b clock pulse generator prom or masked rom* ram* cpu direct memory access controller interrupt controller user break controller bus state controller serial communi- cation interface (2 channels) 16-bit integrated-timer pulse unit programmable timing pattern controller watchdog timer v ss v ss v ss av ss notes: *1. sh7020: 16-kbyte masked rom and 1-kbyte ram. sh7021: 32-kbyte prom or masked rom and 1-kbyte ram. *2. vpp: sh7021 (prom version) 2 1 1 figure 1.1 block diagram
8 hitachi 1.3 pin descriptions 1.3.1 pin arrangement wdtovf nmi v cc xtal extal v ss ck pa15/irq3/dreq1 pa14/irq2/dack1 pa13/irq1/dreq0/tclkb pa12/irq0/dack0/tclka pa11/dph/ticob1 v cc pa10/dpl/tioca1 pa9/ah/irqout pa8/breq v ss pa7/back pa6/rd pa5/wrh(lbs) pa4/wrl(wr) pa3/ca7/wait pa2/cs6/tiocb0 pa1/cs5/ras pa0/cs4/tioca0 ad0 ad1 ad2 v ss ad3 ad4 ad5 ad6 ad7 ad8 ad9 ad10 v cc ad11 v ss ad12 ad13 ad14 ad15 a0(hbs) a1 a2 a3 v ss a4 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 pb15/tp15/irq7 pb14/tp14/irq6 pb13/tp13/irq5/sck1 pb12/tp12/irq4/sck0 pb11/tp11/txd1 pb10/tp10/rxd1 pb9/tp9/txd0 pb8/tp8/rxd0 v ss pb7/tp7/tocxb4/tclkd pb6/tp6/tocxa4/tclkc pb5/tp5/tiocb4 v cc pb4/tp4/tioca4 pb3/tp3/tiocb3 pb2/tp2/tioca3 pb1/tp1/tiocb2 pb0/tp0/tioca2 v ss v ss v cc md2 md1 md0 res(vpp) * a5 a6 a7 a8 a9 a10 v ss a11 a12 a13 a14 a15 v cc a16 a17 v ss a18 a19 a20 a21 cs0 cs1/cash cs2 cs3/casl v ss tfp-100b (top view) notes: vpp: sh7021 (prom version) figure 1.2 pin arrangement
hitachi 9 1.3.2 pin functions table 1.3 describes the pin functions. table 1.3 pin functions type symbol pin no. i/o name and function power v cc 13, 38, 63, 73, 80, 88 i power: connected to the power supply. connect all v cc pins to the system power supply . the chip will not operate if any v cc pin is left unconnected. v ss 4, 15, 24, 32, 41, 50, 59, 70, 81, 82, 92 i ground: connected to ground. connect all v ss pins to the system ground. the chip will not operate if any v ss pin is left unconnected. v pp 76* i res pin in the mcu mode. apply +12.5v when programming the prom in the sh7021 (prom version). clock extal 71 i crystal/external clock: connected to a crystal resonator or external clock input having the same frequency as the system clock (ck). xtal 72 i crystal: connected to a crystal resonator with the same frequency as the system clock (ck). if an external clock is input at the extal pin, leave xtal open. ck 69 o system clock: supplies the system clock (ck) to peripheral devices. system control res 76 i reset: low input causes a power-on reset if nmi is high, or a manual reset if nmi is low. wdtovf 75 o watchdog timer overflow: overflow output signal from the watchdog timer. breq 60 i bus request: driven low by an external device to request the bus ownership. back 58 o bus request acknowledge: indicates that bus ownership has been granted to an external device. by receiving the back signal, a device that has sent a breq signal can confirm that it has been granted the bus. note: pin 76 is res in the sh7020, sh7021 (masked rom version) and vpp in the sh7021 (prom version).
10 hitachi table 1.3 pin functions (cont) type symbol pin no. i/o name and function operating mode control md2, md1, md0 79?7 i mode select: selects the operating mode. do not change these inputs while the chip is operating. the following table lists the possible operating modes and their corresponding md2?d0 values. md2 md1 md0 operating mode on-chip rom bus size in area 0 0 0 0 mcu mode disabled 8 bits 0 0 1 16 bits 0 1 0 enabled * 1 0 1 1 (reserved) 10 0 10 1 11 0 1 1 1 prom mode * 2 interrupts nmi 74 i nonmaskable interrupt: nonmaskable interrupt request signal. the rising or falling edge can be selected for signal detection. irq0 irq7 65?8, 97?00 i interrupt request 0?: maskable interrupt request signals. level input or edge-triggered input can be selected. irqout 61 o slave interrupt request output: indicates occurrence of an interrupt while the bus is released. address bus a21?0 45?2, 40, 39, 37?3, 31?5, 23?0 o address bus: outputs addresses. data bus ad15 ad0 19?6, 14, 12-5, 3? i/o data bus: 16-bit bidirectional data bus that is multiplexed with the lower 16 bits of the address bus. dph 64 i/o upper data bus parity: parity data for d15?8. dpl 62 i/o lower data bus parity: parity data for d7?0. bus control wait 54 i wait: requests the insertion of wait states (t w ) into the bus cycle when the external address space is accessed. notes : 1.use prohibited in the sh7020 romless version. 2.can only be used in the sh7021 ztat version.
hitachi 11 table 1.3 pin functions (cont) type symbol pin no. i/o name and function bus control ras 52 o row address strobe: dram row-address strobe-timing signal. (cont) cash 47 o column address strobe high: dram column-address strobe-timing signal outputs low level to access the upper eight data bits. casl 49 o column address strobe low: dram column-address strobe-timing signal outputs low level to access the lower eight data bits. rd 57 o read: indicates reading of data from an external device. wrh 56 o upper write: indicates write access to the upper eight bits of an external device. wrl 55 o lower write: indicates write access to the lower eight bits of an external device. cs0 cs7 46?9, 51?4 o chip select 0?: chip select signals for accessing external memory and devices. ah 61 o address hold: address hold timing signal for a device using a multiplexed address/data bus. hbs , lbs 20, 56 o upper/lower byte strobe: upper and lower byte strobe signals. (also used as wrh and a0.) wr 55 o write: brought low during write access. (also used as wrl .) dmac dreq0 , dreq1 66, 68 i dma transfer request (channels 0 and 1): input pins for external dma transfer requests. dack0, dack1 65, 67 o dma transfer acknowledge (channels 0 and 1): indicates that dma transfer is acknowledged. 16-bit integrated- tioca0, tiocb0 51, 53 i/o itu input capture/output compare (channel 0): input capture or output compare pins. timer pulse unit (itu) tioca1, tiocb1 62, 64 i/o itu input capture/output compare (channel 1): input capture or output compare pins. tioca2, tiocb2 83, 84 i/o itu input capture/output compare (channel 2): input capture or output compare pins. tioca3, tiocb3 85, 86 i/o itu input capture/output compare (channel 3): input capture or output compare pins. tioca4, tiocb4 87, 89 i/o itu input capture/output compare (channel 4): input capture or output compare pins.
12 hitachi table 1.3 pin functions (cont) type symbol pin no. i/o name and function 16-bit integrated- tocxa4, tocxb4 90, 91 o itu output compare (channel 4): output compare pins. timer pulse unit (itu) tclka tclkd 65, 66, 90, 91 i itu timer clock input: external clock input pins for itu counters. timing pattern controller (tpc) tp15 tp0 100?3, 91?9, 87?3 o timing pattern output 15?: timing pattern output pins. serial com- munication txd0, txd1 94, 96 o transmit data (channels 0 and 1): transmit data output pins for sci0 and sci1. interface (sci) rxd0, rxd1 93, 95 i receive data (channels 0 and 1): receive data input pins for sci0 and sci1. sck0, sck1 97, 98 i/o serial clock (channels 0 and 1): clock input/output pins for sci0 and sci1. i/o ports pa15 pa0 68?4, 62?0, 58-51 i/o port a: 16-bit input/output pins. input or output can be selected individually for each bit. pb15 pb0 100?3, 91?9, 87?3 i/o port b: 16-bit input/output pins. input or output can be selected individually for each bit.
hitachi 13 1.3.3 pin layout by mode table 1.4 shows pin layout by mode table 1.4 pin layout by mode pin no. mcu mode prom mode (sh7021pr- om version) pin no. mcu mode prom mode (sh7021pr- om version) 1 ad0 ad0 29 a8 a8 2 ad1 ad1 30 a9 oe 3 ad2 ad2 31 a10 a10 4 vss vss 32 v ss v ss 5 ad3 ad3 33 a11 a11 6 ad4 ad4 34 a12 a12 7 ad5 ad5 35 a13 a13 8 ad6 ad6 36 a14 a14 9 ad7 ad7 37 a15 a15 10 ad8 nc 38 v cc v cc 11 ad9 nc 39 a16 a16 12 ad10 nc 40 a17 v cc 13 v cc v cc 41 v ss v ss 14 ad11 nc 42 a18 v cc 15 v ss v ss 43 a19 nc 16 ad12 nc 44 a20 nc 17 ad13 nc 45 a21 nc 18 ad14 nc 46 cs0 nc 19 ad15 nc 47 cs1 / cash nc 20 a0( hbs )a0 48 cs2 nc 21 a1 a1 49 cs3 / casl nc 22 a2 a2 50 v ss v ss 23 a3 a3 51 pa0/ cs4 /tioca0 nc 24 v ss v ss 52 pa1/ cs5 / ras nc 25 a4 a4 53 pa2/ cs6 / tiocb0 pgm 26 a5 a5 54 pa3/ cs7 / wait ce 27 a6 a6 55 pa4/ wrl ( wr )nc 28 a7 a7 56 pa5/ wrh ( lbs )nc
14 hitachi table 1.3.3 pin layout by mode (cont) pin no. mcu mode prom mode (sh7021pr- om version) pin no. mcu mode prom mode (sh7021pr- om version) 57 pa6/ rd nc 80 v cc v cc 58 pa7/ back nc 81 v ss v ss 59 v ss v ss 82 v ss v ss 60 pa8/ breq nc 83 pb0/tp0/tioca2 nc 61 pa9/ ah / irqout nc 84 pb1/tp1/tiocb2 nc 62 pa10/dpl/tioca1 nc 85 pb2/tp2/tioca3 nc 63 v cc v cc 86 pb3/tp3/tiocb3 nc 64 pa11/dph/tiocb1 nc 87 pb4/tp4/tioca4 nc 65 pa12/ irq0 /dack0/ nc 88 v cc v cc tclka 89 pb5/tp5/tiocb4 nc 66 pa13/ irq1 / dreq0 / nc 90 pb6/tp6/tocxa4/ nc tclklb tclkc 67 pa14/ irq2 /dack1 nc 91 pb7/tp7/tocxb4/ nc 68 pa15/ irq3 /dreq1 nc tclkd 69 ck nc 92 v ss v ss 70 v ss v ss 93 pb8/tp8/rxd0 nc 71 extal nc 94 pb9/tp9/txd0 nc 72 xtal nc 95 pb10/tp10/rxd1 nc 73 v cc v cc 96 pb11/tp11/txd1 nc 74 nmi a9 97 pb12/tp12/ irq4 /nc 75 wdtovf nc sck0 76 res v pp 98 pb13/tp13/ irq5 /nc 77 md0 v cc sck1 78 md1 v cc 99 pb14/tp14/ irq6 nc 79 md2 v cc 100 pb15/tp15/ irq7 nc
hitachi 15 section 2 cpu 2.1 register configuration the register set consists of sixteen 32-bit general registers, three 32-bit control registers, and four 32-bit system registers. 2.1.1 general registers (rn) general registers rn consist of sixteen 32-bit registers (r0?15). general registers are used for data processing and address calculation. register r0 also functions as an index register. for some instructions, the r0 register must be used. register r15 functions as a stack pointer to save or recover status registers (sr) and program counter (pc) during exception processing. r0 r1 r2 r3 r4 r5 r6 r7 r8 r9 r10 r11 r12 r13 r14 r15, sp 0 31 r0 functions as an index register in the indexed register addressing mode and indirect indexed gbr addressing mode. in some instruc- tions, r0 functions as a source register or a destination register. r15 functions as a stack pointer (sp) during exception processing. figure 2.1 general registers (rn) 2.1.2 control registers control registers consist of the 32-bit status register (sr), global base register (gbr), and vector base register (vbr). the status register indicates processing states. the global base register
16 hitachi functions as a base address for the indirect gbr addressing mode to transfer data to the registers of peripheral on-chip modules. the vector base register functions as the base address of the exception processing vector area including interrupts. 9876543210 mqi3 i2 i1 i0 st 0 0 31 31 gbr vbr sr 31 s bit: used by the mac instruction. reserved bits. these bits always read 0. the write value should always be 0. bits i0?3: interrupt mask bits. m and q bits: used by the div0u, div0s, and div1 instructions. global base register (gbr): indicates the base address of the indirect gbr addressing mode. the indirect gbr addressing mode is used to transfer data to the register areas peripheral on-chip modules. vector base register (vbr): stores the base address of the exception processing vector area. sr: status register t bit: the movt, cmp, tas, tst, bt, bf, sett, and clrt instructions use the t bit to indicate a true (1) or false (0). the addv, addc, subv, subc, div0u, div0s, div1, negc, shar, shal, shlr, shll, rotr, rotl, rotcr and rotcl instructions also use the t bit to indicate carry/borrow or overflow/underflow figure 2.2 control registers 2.1.3 system registers system registers consist of four 32-bit registers: multiply and accumulate registers high and low (mach and macl), procedure register (pr), and program counter (pc). the multiply and accumulate registers store the results of multiply and accumulate operations. the procedure register stores the return address from the subroutine procedure. the program counter stores program addresses to control the flow of the processing.
hitachi 17 macl pr pc (sign extended) mach 31 9 0 0 0 31 31 multiply and accumulate (mac) registers high and low (mach, macl): store the results of multiply and accumulate opera- tions. mach is sign-extended when read because only the lowest 10 bits are valid. procedure register (pr): stores a return address from a subroutine procedure. program counter (pc): indicates the fourth byte (second instruction) after the current instruction. figure 2.3 system registers 2.1.4 initial values of registers table 2.1 lists the values of the registers after reset. table 2.1 initial values of registers classification register initial value general register r0?14 undefined r15 (sp) value of the stack pointer in the vector address table control register sr bits i0-i3 are 1111(h'f), reserved bits are 0, and other bits are undefined gbr undefined vbr h'00000000 system register mach, macl, pr undefined pc value of the program counter in the vector address table 2.2 data formats 2.2.1 data format in registers register operands are always long words (32 bits). when the memory operand is only a byte (8 bits) or a word (16 bits), it is sign-extended into a long word when stored into a register (figure 2.4).
18 hitachi 31 0 long word figure 2.4 data format in registers 2.2.2 data format in memory memory data formats are classified into bytes, words, and long words. byte data can be accessed from any address, but an address error will occur if you try to access word data starting from an address other than 2n or long word data starting from an address other than 4n. in such cases, the data accessed cannot be guaranteed. the hardware stack area, which is referred to by the hardware stack pointer (sp, r15), uses only long word data starting from address 4n because this area stores the program counter and status register (figure 2.5). 31 0 70 15 0 31 0 7 7 15 7 23 7 byte 0 0 0 15 0 byte byte byte word word long word address 2n address 4n address m address m + 2 address m + 1 address m + 3 figure 2.5 data format in memory 2.2.3 immediate data format byte (8-bit) immediate data is located in the instruction code. immediate data accessed by the mov, add, and cmp/eq instructions is sign-extended and is handled in registers as long word data. immediate data accessed by the tst, and, or, and xor instructions is zero-extended and is handled as long word data. consequently, and instructions with immediate data always clear the upper 24 bits of the destination register. word or long word immediate data is not located in the instruction code but rather is stored in a memory table. the memory table is accessed by a immediate data transfer instruction (mov) using the pc relative addressing mode with displacement.
hitachi 19 2.3 instruction features 2.3.1 risc-type instruction set all instructions are risc type. their features are as follows: 16-bit fixed length: every instruction is 16 bits long, making program coding much more efficient. one instruction/cycle: basic instructions can be executed in one cycle using the pipeline system. one-cycle instructions are executed in 50 ns at 20 mhz. data length: long word is the standard data length for all operations. memory can be accessed in bytes, words, or long words. byte or word data accessed from memory is sign-extended and handled as long word data. immediate data is sign-extended for arithmetic operations or zero- extended for logic operations (handled as long word data). table 2.2 sign extension of word data cpu of sh7000 series description conventional cpus mov.w @(disp,pc),r1 add r1,r0 ........................ .data.w h'1234 data is sign-extended to 32 bits, and r1 becomes h'00001234. it is next operated upon by an add instruction. add.w #h'1234, r0 note: the address of the immediate data is accessed by @(disp, pc). load-store architecture: basic operations are executed between registers. for operations that involve memory, data is loaded to the registers and executed (load-store architecture). instructions such as and that manipulate bits, however, are executed directly in memory. delayed branch instructions: unconditional branch instructions are delayed. pipeline disruption during branching is reduced by first executing the instruction that follows the branch instruction, and then branching. see the sh-1/sh-2 programming manual for details. table 2.3 delayed branch instructions cpu of sh7000 series description conventional cpu bra trget add r1, r0 executes an add before branching to trget. add.w r1, r0 bra trget multiplication/accumulation operation: the five-stage pipeline system and the on-chip multiplier enable 16-bit 16-bit ? 32-bit multiplication operations to be executed in 1? cycles. 16-bit 16-bit + 42-bit ? 42-bit multiplication/accumulation operations can be executed in 2? cycles.
20 hitachi t bit: t bit (in the status register) is set according to the result of a comparison, and in turn is the condition (true/false) that determines if the program will branch. the t bit in the status register is only changed by selected instructions, thus improving the processing speed. table 2.4 t bit cpu of sh7000 series description conventional cpu cmp/ge r1, r0 bt trget0 bf trget1 t bit is set when r0 3 r1. the program branches to trget0 when r0 3 r1 and to trget1 when r0 hitachi 21 table 2.6 absolute address accessing classification cpu of sh7000 series conventional cpu absolute address mov.l @(disp,pc), r1 mov. b @r1, r0 ......... .data.l h'12345678 mov.b @h'12345678, r0 note: the address of the immediate data is accessed by @(disp, pc). 16/32-bit displacement: when data is accessed by 16-bit or 32-bit displacement, the pre-existing displacement value is placed in the memory table. by loading the immediate data when the instruction is executed, that value is transferred to the register and the data is accessed in the indirect indexed register addressing mode. table 2.7 accessing by displacement classification cpu of sh7000 series conventional cpu 16-bit displacement mov.w @(disp, pc), r0 mov.w @(r0, r1), r2 ......... .data.w h'1234 mov.w @(h'1234, r1), r2 note: the address of the immediate data is accessed by @(disp, pc).
22 hitachi 2.3.2 addressing modes addressing modes and effective address calculation are described in table 2.8. table 2.8 addressing modes and effective addresses addressing mode mnemonic expression effective addresses calculation equation direct register addressing rn the effective address is register rn. (the operand is the contents of register rn.) indirect register addressing @rn the effective address is the content of register rn. rn rn rn post-incre- ment indirect register addressing @rn + the effective address is the content of register rn. a constant is added to the content of rn after the instruction is executed. 1 is added for a byte operation, 2 for a word operation, and 4 for a long word operation. rn rn 1/2/4 + rn + 1/2/4 rn (after the instruction is executed) byte: rn + 1 ? rn word: rn + 2 ? rn long word: rn + 4 ? rn pre-decre- ment indirect register addressing @?n the effective address is the value obtained by subtracting a constant from rn. 1 is subtracted for a byte operation, 2 for a word operation, and 4 for a long word operation. rn 1/2/4 rn ?1/2/4 rn ?1/2/4 byte: rn ?1 ? rn word: rn ?2 ? rn long word: rn ?4 ? rn (instruction executed with rn after calculation)
hitachi 23 table 2.8 addressing modes and effective addresses (cont) addressing mode mnemonic expression effective addresses calculation equation indirect register addressing with displace- ment @(disp:4, rn) the effective address is rn plus a 4-bit displacement (disp). disp is zero-extended, and remains the same for a byte operation, is doubled for a word operation, and is quadrupled for a long word operation. rn rn + disp 1/2/4 + 1/2/4 disp (zero-extended) byte: rn + disp word: rn + disp 2 long word: rn + disp 4 indirect indexed register addressing @(r0, rn) the effective address is the rn value plus r0. rn r0 rn + r0 + rn + r0 indirect gbr addressing with displace- ment @(disp:8, gbr) the effective address is the gbr value plus an 8-bit displacement (disp). the value of disp is zero- extended, and remains the same for a byte operation, is doubled for a word operation, and is quadrupled for a long word operation. gbr 1/2/4 gbr + disp 1/2/4 + disp (zero-extended) byte: gbr + disp word: gbr + disp 2 long word: gbr + disp 4 indirect indexed gbr addressing @(r0, gbr) the effective address is the gbr value plus the r0. gbr r0 gbr + r0 + gbr + r0
24 hitachi table 2.8 addressing modes and effective addresses (cont) addressing mode mnemonic expression effective addresses calculation equation pc relative addressing with dis- placement @(disp:8, pc) the effective address is the pc value plus an 8-bit displacement (disp). disp is zero-extended, and remains the same for a byte operation, is doubled for a word operation, and is quadrupled for a long word operation. for a long word operation, the lowest two bits of the pc are masked. pc h'fffffffc pc + disp 2 or pc & h'fffffffc + disp 4 + 2/4 & * disp (zero-extended) *: for long word word: pc + disp 2 long word: pc & h'fffffffc + disp 4 pc relative addressing disp:8 the effective address is the pc value sign-extended with an 8-bit displacement (disp), doubled, and added to the pc. pc 2 + disp (zero-extended) pc + disp 2 pc + disp 2 disp:12 the effective address is the pc value sign-extended with a 12-bit displacement (disp), doubled, and added to the pc. pc 2 + disp (zero-extended) pc + disp 2 pc + disp 2
hitachi 25 table 2.8 addressing modes and effective addresses (cont) addressing mode mnemonic expression effective addresses calculation equation immediate addressing #imm:8 the 8-bit immediate data (imm) for the tst, and, or, and xor instructions are zero-extended. #imm:8 the 8-bit immediate data (imm) for the mov, add, and cmp/eq instructions are sign-extended. #imm:8 immediate data (imm) for the trapa instruction is zero-extended and is quadrupled. 2.3.3 instruction formats the instruction format refers to the source operand and the destination operand. the meaning of the operand depends on the instruction code. symbols are as follows. xxxx instruction code mmmm source register nnnn destination register iiii immediate data dddd displacement table 2.9 instruction formats instruction formats source operand destination operand instruction example 0 format xxxx xxxx xxxx xxxx 15 0 nop n format nnnn: direct register movt rn xxxx xxxx xxxx nnnn 15 0 control register or system register nnnn: direct register sts mach,rn control register or system register nnnn: indirect pre- decrement register stc.l sr,@-rn
26 hitachi table 2.9 instruction formats (cont) instruction formats source operand destination operand instruction example m format mmmm: direct register control register or system register ldc rm,sr xxxx mmmm xxxx xxxx 15 0 mmmm: indirect post-increment register control register or system register ldc.l @rm+,sr mmmm: direct register jmp @rm nm format mmmm: direct register nnnn: direct register add rm,rn nnnn xxxx xxxx 15 0 mmmm mmmm: direct register nnnn: direct register mov.l rm,@rn mmmm: indirect post-increment register (multiply/ accumulate) nnnn: indirect post-increment register (multiply/ accumulate)* mach, macl mac.w @rm+,@rn+ mmmm: indirect post-increment register nnnn: direct register mov.l @rm+,rn mmmm: direct register nnnn: indirect pre- decrement register mov.l rm,@-rn mmmm: direct register nnnn: indirect indexed register mov.l rm,@(r0,rn) md format xxxx dddd 15 0 mmmm xxxx mmmmdddd: indirect register with displacement r0 (direct register) mov.b @(disp,rm),r0 nd4 format xxxx dddd 15 0 nnnn xxxx r0 (direct register) nnnndddd: indirect register with displacement mov.b r0,@(disp,rn) note: in mac instructions, nnnn is the source register.
hitachi 27 table 2.9 instruction formats (cont) instruction formats source operand destination operand example nmd format nnnn xxxx dddd 15 0 mmmm mmmm: direct register nnnndddd: indirect register with displacement mov.l rm,@(disp,rn) mmmmdddd: indirect register with displacement nnnn: direct register mov.l @(disp,rm),rn d format dddd xxxx 15 0 xxxx dddd dddddddd: indirect gbr with displacement r0 (direct register) mov.l @(disp,gbr),r0 r0(direct register) dddddddd: indirect gbr with displacement mov.l r0,@(disp,gbr) dddddddd: pc relative with displacement r0 (direct register) mova @(disp,pc),r0 dddddddd: pc relative bf disp d12 format dddd xxxx 15 0 dddd dddd dddddddddddd: pc relative bra disp nd8 format dddd nnnn xxxx 15 0 dddd dddddddd: pc relative with displacement nnnn: direct register mov.l @(disp,pc),rn i format iiiiiiii: immediate indirect indexed gbr and.b #imm,@(r0,gbr) xxxx xxxx i i i i 15 0 i i i i iiiiiiii: immediate r0 (direct register) and #imm,r0 iiiiiiii: immediate trapa #imm ni format nnnn i i i i xxxx 15 0 i i i i iiiiiiii: immediate nnnn: direct register add #imm,rn
28 hitachi 2.4 instruction set 2.4.1 instruction set by classification table 2.10 lists instructions by classification. table 2.10 classification of instructions classifi- cation types operation code function number of instructions data transfer 5 mov data transfer, immediate data transfer, peripheral module data transfer, structure data transfer 39 mova effective address transfer movt t bit transfer swap swap of upper and lower bytes xtrct extraction of the middle of registers connected arithmetic 17 add binary addition 28 operations addc binary addition with carry addv binary addition with overflow check cmp/cond comparison div1 division div0s initialization of signed division div0u initialization of unsigned division exts sign extension extu zero extension mac multiplication and accumulation muls signed multiplication mulu unsigned multiplication neg negation negc negation with borrow sub binary subtraction subc binary subtraction with carry subv binary subtraction with underflow check logic 6 and logical and 14 operations not bit inversion or logical or tas memory test and bit set
hitachi 29 table 2.10 classification of instructions (cont) classifi- cation types operation code function number of instructions logic oper- 6 tst logical and and t bit set 14 ations(cont) xor exclusive or shift 10 rotl one-bit left rotation 14 rotr one-bit right rotation rotcl one-bit left rotation with t bit rotcr one-bit right rotation with t bit shal one-bit arithmetic left shift shar one-bit arithmetic right shift shll one-bit logical left shift shlln n-bit logical left shift shlr one-bit logical right shift shlrn n-bit logical right shift branch 7 bf conditional branch (t = 0) 7 bt conditional branch (t = 1) bra unconditional branch bsr branch to subroutine procedure jmp unconditional branch jsr branch to subroutine procedure rts return from subroutine procedure system 11 clrt t bit clear 31 control clrmac mac register clear ldc load to control register lds load to system register nop no operation rte return from exception processing sett t bit set sleep shift into power-down mode stc storing control register data sts storing system register data trapa trap exception processing total 56 133
30 hitachi instruction codes, operation, and execution states are listed in the following format in order by classification. table 2.11 instruction code format item format explanation instruction mnemonic op.sz src,dest op: operation code sz: size src: source dest: destination rm: source register rn: destination register imm: immediate data disp: displacement* instruction code msb ? lsb mmmm: source register nnnn: destination register 0000: r0 0001: r1 ........... 1111: r15 iiii: immediate data dddd: displacement operation summary ? , ? (xx) m/q/t & | ^ ~ <>n direction of transfer memory operand flag bits in the sr logical and of each bit logical or of each bit exclusive or of each bit logical not of each bit n-bit shift execution value when no wait states are inserted cycle instruction execution cycles: the execution cycles shown in the table are minimums. the actual number of cycles may be increased: 1. when contention occurs between instruction fetches and data access, or 2. when the destination register of the load instruction (memory ? register) and the register used by the next instruction are the same. t bit value of t bit after instruction is executed no change note: scaling ( 1, 2, 4) is performed according to the instruction operand size. see "sh-1/sh-2 programming manual" for details.
hitachi 31 table 2.12 data transfer instructions instruction instruction code operation execu- tion cycles t bit mov #imm,rn 1110nnnniiiiiiii #imm ? sign extension ? rn 1 mov.w @(disp,pc),rn 1001nnnndddddddd (disp 2 + pc) ? sign extension ? rn 1 mov.l @(disp,pc),rn 1101nnnndddddddd (disp 4 + pc) ? rn 1 mov rm,rn 0110nnnnmmmm0011 rm ? rn 1 mov.b rm,@rn 0010nnnnmmmm0000 rm ? (rn) 1 mov.w rm,@rn 0010nnnnmmmm0001 rm ? (rn) 1 mov.l rm,@rn 0010nnnnmmmm0010 rm ? (rn) 1 mov.b @rm,rn 0110nnnnmmmm0000 (rm) ? sign extension ? rn 1 mov.w @rm,rn 0110nnnnmmmm0001 (rm) ? sign extension ? rn 1 mov.l @rm,rn 0110nnnnmmmm0010 (rm) ? rn 1 mov.b rm,@?n 0010nnnnmmmm0100 rn? ? rn, rm ? (rn) 1 mov.w rm,@?n 0010nnnnmmmm0101 rn? ? rn, rm ? (rn) 1 mov.l rm,@?n 0010nnnnmmmm0110 rn? ? rn, rm ? (rn) 1 mov.b @rm+,rn 0110nnnnmmmm0100 (rm) ? sign extension ? rn,rm + 1 ? rm 1 mov.w @rm+,rn 0110nnnnmmmm0101 (rm) ? sign extension ? rn,rm + 2 ? rm 1 mov.l @rm+,rn 0110nnnnmmmm0110 (rm) ? rn,rm + 4 ? rm 1 mov.b r0,@(disp,rn) 10000000nnnndddd r0 ? (disp + rn) 1 mov.w r0,@(disp,rn) 10000001nnnndddd r0 ? (disp 2 + rn) 1 mov.l rm,@(disp,rn) 0001nnnnmmmmdddd rm ? (disp 4 + rn) 1 mov.b @(disp,rm),r0 10000100mmmmdddd (disp + rm) ? sign extension ? r0 1 mov.w @(disp,rm),r0 10000101mmmmdddd (disp 2 + rm) ? sign extension ? r0 1 mov.l @(disp,rm),rn 0101nnnnmmmmdddd (disp 4 + rm) ? rn 1 mov.b rm,@(r0,rn) 0000nnnnmmmm0100 rm ? (r0 + rn) 1 mov.w rm,@(r0,rn) 0000nnnnmmmm0101 rm ? (r0 + rn) 1
32 hitachi table 2.12 data transfer instructions (cont) instruction instruction code operation execu- tion cycles t bit mov.l rm,@(r0,rn) 0000nnnnmmmm0110 rm ? (r0 + rn) 1 mov.b @(r0,rm),rn 0000nnnnmmmm1100 (r0 + rm) ? sign extension ? rn 1 mov.w @(r0,rm),rn 0000nnnnmmmm1101 (r0 + rm) ? sign extension ? rn 1 mov.l @(r0,rm),rn 0000nnnnmmmm1110 (r0 + rm) ? rn 1 mov.b r0,@(disp,gbr) 11000000dddddddd r0 ? (disp + gbr) 1 mov.w r0,@(disp,gbr) 11000001dddddddd r0 ? (disp 2 + gbr) 1 mov.l r0,@(disp,gbr) 11000010dddddddd r0 ? (disp 4 + gbr) 1 mov.b @(disp,gbr),r0 11000100dddddddd (disp + gbr) ? sign extension ? r0 1 mov.w @(disp,gbr),r0 11000101dddddddd (disp 2 + gbr) ? sign extension ? r0 1 mov.l @(disp,gbr),r0 11000110dddddddd (disp 4 + gbr) ? r0 1 mova @(disp,pc),r0 11000111dddddddd disp 4 + pc ? r0 1 movt rn 0000nnnn00101001 t ? rn 1 swap.b rm,rn 0110nnnnmmmm1000 rm ? swap the bottom two bytes ? rn 1 swap.w rm,rn 0110nnnnmmmm1001 rm ? swap two consecutive words ? rn 1 xtrct rm,rn 0010nnnnmmmm1101 center 32 bits of rm and rn ? rn 1
hitachi 33 table 2.13 arithmetic instructions instruction instruction code operation execution cycles t bit add rm,rn 0011nnnnmmmm1100 rn + rm ? rn 1 add #imm,rn 0111nnnniiiiiiii rn + imm ? rn 1 addc rm,rn 0011nnnnmmmm1110 rn + rm + t ? rn, carry ? t 1 carry addv rm,rn 0011nnnnmmmm1111 rn + rm ? rn, overflow ? t 1 overflow cmp/eq #imm,r0 10001000iiiiiiii if r0 = imm, 1 ? t 1 comparison result cmp/eq rm,rn 0011nnnnmmmm0000 if rn = rm, 1 ? t 1 comparison result cmp/hs rm,rn 0011nnnnmmmm0010 if rn 3 rm with unsigned data, 1 ? t 1 comparison result cmp/ge rm,rn 0011nnnnmmmm0011 if rn 3 rm with signed data, 1 ? t 1 comparison result cmp/hi rm,rn 0011nnnnmmmm0110 if rn > rm with unsigned data, 1 ? t 1 comparison result cmp/gt rm,rn 0011nnnnmmmm0111 if rn > rm with signed data, 1 ? t 1 comparison result cmp/pz rn 0100nnnn00010001 if rn 3 0, 1 ? t 1 comparison result cmp/pl rn 0100nnnn00010101 if rn > 0, 1 ? t 1 comparison result cmp/str rm,rn 0010nnnnmmmm1100 if rn and rm have an equivalent byte, 1 ? t 1 comparison result div1 rm,rn 0011nnnnmmmm0100 single-step division (rn/rm) 1 calculation result div0s rm,rn 0010nnnnmmmm0111 msb of rn ? q, msb of rm ? m, m? q ? t 1 calculation result div0u 0000000000011001 0 ? m/q/t 1 0 exts.b rm,rn 0110nnnnmmmm1110 a byte in rm is sign- extended ? rn 1
34 hitachi table 2.13 arithmetic instructions (cont) instruction instruction code operation execution cycles t bit exts.w rm,rn 0110nnnnmmmm1111 a word in rm is sign- extended ? rn 1 extu.b rm,rn 0110nnnnmmmm1100 a byte in rm is zero- extended ? rn 1 extu.w rm,rn 0110nnnnmmmm1101 a word in rm is zero- extended ? rn 1 mac.w @rm+,@rn+ 0100nnnnmmmm1111 signed operation of (rn) (rm) + mac ? mac 3/(2)* muls rm,rn 0010nnnnmmmm1111 signed operation of rn rm ? mac 1?* mulu rm,rn 0010nnnnmmmm1110 unsigned operation of rn rm ? mac 1?* neg rm,rn 0110nnnnmmmm1011 0?m ? rn 1 negc rm,rn 0110nnnnmmmm1010 0?m? ? rn, borrow ? t 1 borrow sub rm,rn 0011nnnnmmmm1000 rn?m ? rn 1 subc rm,rn 0011nnnnmmmm1010 rn?m? ? rn, borrow ? t 1 borrow subv rm,rn 0011nnnnmmmm1011 rn?m ? rn, underflow ? t 1 underflow note: the normal minimum number of execution cycles (the number in parenthesis in the number of cycles when there is contension with preceding/following instructions).
hitachi 35 table 2.14 logic operation instructions instruction instruction code operation execution cycles t bit and rm,rn 0010nnnnmmmm1001 rn & rm ? rn 1 and #imm,r0 11001001iiiiiiii r0 & imm ? r0 1 and.b #imm,@(r0,gbr) 11001101iiiiiiii (r0 + gbr) & imm ? (r0 + gbr) 3 not rm,rn 0110nnnnmmmm0111 ~rm ? rn 1 or rm,rn 0010nnnnmmmm1011 rn | rm ? rn 1 or #imm,r0 11001011iiiiiiii r0 | imm ? r0 1 or.b #imm,@(r0,gbr) 11001111iiiiiiii (r0 + gbr) | imm ? (r0 + gbr) 3 tas.b @rn 0100nnnn00011011 if (rn) is 0, 1 ? t; 1 ? msb of (rn) 4 test result tst rm,rn 0010nnnnmmmm1000 rn & rm; if the result is 0, 1 ? t 1 test result tst #imm,r0 11001000iiiiiiii r0 & imm; if the result is 0, 1 ? t 1 test result tst.b #imm,@(r0,gbr) 11001100iiiiiiii (r0 + gbr) & imm; if the result is 0, 1 ? t 3 test result xor rm,rn 0010nnnnmmmm1010 rn ^ rm ? rn1 xor #imm,r0 11001010iiiiiiii r0 ^ imm ? r0 1 xor.b #imm,@(r0,gbr) 11001110iiiiiiii (r0 + gbr) ^ imm ? (r0 + gbr) 3
36 hitachi table 2.15 shift instructions instruction instruction code operation execution cycles t bit rotl rn 0100nnnn00000100 t ? rn ? msb 1 msb rotr rn 0100nnnn00000101 lsb ? rn ? t 1 lsb rotcl rn 0100nnnn00100100 t ? rn ? t 1 msb rotcr rn 0100nnnn00100101 t ? rn ? t 1 lsb shal rn 0100nnnn00100000 t ? rn ? 0 1 msb shar rn 0100nnnn00100001 msb ? rn ? t 1 lsb shll rn 0100nnnn00000000 t ? rn ? 0 1 msb shlr rn 0100nnnn00000001 0 ? rn ? t 1 lsb shll2 rn 0100nnnn00001000 rn<<2 ? rn 1 shlr2 rn 0100nnnn00001001 rn>>2 ? rn 1 shll8 rn 0100nnnn00011000 rn<<8 ? rn 1 shlr8 rn 0100nnnn00011001 rn>>8 ? rn 1 shll16 rn 0100nnnn00101000 rn<<16 ? rn 1 shlr16 rn 0100nnnn00101001 rn>>16 ? rn 1 table 2.16 branch instructions instruction instruction code operation executio n cycles t bit bf label 10001011dddddddd if t = 0, disp 2 + pc ? pc; if t = 1, nop 3/1* bt label 10001001dddddddd if t = 1, disp 2 + pc ? pc; if t = 0, nop 3/1* bra label 1010dddddddddddd delayed branch, disp 2 + pc ? pc 2 bsr label 1011dddddddddddd delayed branch, pc ? pr, disp 2 + pc ? pc 2 jmp @rm 0100mmmm00101011 delayed branch, rm ? pc 2 jsr @rm 0100mmmm00001011 delayed branch, pc ? pr, rm ? pc 2 rts 0000000000001011 delayed branch, pr ? pc 2 note: the execution state is three cycles when program branches, and one cycle when program does not branch.
hitachi 37 table 2.17 system control instructions instruction instruction code operation execution cycles t bit clrt 0000000000001000 0 ? t10 clrmac 0000000000101000 0 ? mach, macl 1 ldc rm,sr 0100mmmm00001110 rm ? sr 1 lsb ldc rm,gbr 0100mmmm00011110 rm ? gbr 1 ldc rm,vbr 0100mmmm00101110 rm ? vbr 1 ldc.l @rm+,sr 0100mmmm00000111 (rm) ? sr, rm + 4 ? rm 3 lsb ldc.l @rm+,gbr 0100mmmm00010111 (rm) ? gbr, rm + 4 ? rm 3 ldc.l @rm+,vbr 0100mmmm00100111 (rm) ? vbr, rm + 4 ? rm 3 lds rm,mach 0100mmmm00001010 rm ? mach 1 lds rm,macl 0100mmmm00011010 rm ? macl 1 lds rm,pr 0100mmmm00101010 rm ? pr 1 lds.l @rm+,mach 0100mmmm00000110 (rm) ? mach, rm + 4 ? rm 1 lds.l @rm+,macl 0100mmmm00010110 (rm) ? macl, rm + 4 ? rm 1 lds.l @rm+,pr 0100mmmm00100110 (rm) ? pr, rm + 4 ? rm 1 nop 0000000000001001 no operation 1 rte 0000000000101011 delayed branch, stack area ? pc/sr 4 sett 0000000000011000 1 ? t11 sleep 0000000000011011 sleep 3* stc sr,rn 0000nnnn00000010 sr ? rn 1 stc gbr,rn 0000nnnn00010010 gbr ? rn 1 stc vbr,rn 0000nnnn00100010 vbr ? rn 1 stc.l sr,@?n 0100nnnn00000011 rn? ? rn, sr ? (rn) 2 stc.l gbr,@?n 0100nnnn00010011 rn? ? rn, gbr ? (rn) 2 stc.l vbr,@?n 0100nnnn00100011 rn? ? rn, vbr ? (rn) 2 sts mach,rn 0000nnnn00001010 mach ? rn 1 sts macl,rn 0000nnnn00011010 macl ? rn 1 sts rr,rn 0000nnnn00101010 pr ? rn 1 note: the number of execution states before the chip enters the sleep state.
38 hitachi table 2.17 system control instructions (cont) instruction instruction code operation execution cycles t bit sts.l mach,@?n 0100nnnn00000010 rn? ? rn, mach ? (rn) 1 sts.l macl,@?n 0100nnnn00010010 rn? ? rn, macl ? (rn) 1 sts.l pr,@?n 0100nnnn00100010 rn? ? rn, pr ? (rn) 1 trapa #imm 11000011iiiiiiii pc/sr ? stack area, (imm 4+vbr) ? pc 8 note: instruction execution cycles: the execution cycles shown in the table are minimums. the actual number of cycles may be increased: 1. when contention occurs between instruction fetches and data access, or 2. when the destination register of the load instruction (memory ? register) and the register used by the next instruction are the same.
hitachi 39 2.4.2 operation code map table 2.18 is an operation code map. table 2.18 operation code map instruction code fx: 0000 fx: 0001 fx: 0010 fx: 0011?111 msb lsb md: 00 md: 01 md: 10 md: 11 0000 rn fx 0000 0000 rn fx 0001 0000 rn fx 0010 stc sr,rn stc gbr,rn stc vbr,rn 0000 rn fx 0011 0000 rn rm 01md mov.b rm, @(r0,rn) mov.w rm, @(r0,rn) mov.l rm, @(r0,rn) 0000 0000 fx 1000 clrt sett clrmac 0000 0000 fx 1001 nop divou 0000 0000 fx 1010 0000 0000 fx 1011 rts sleep rte 0000 rn fx 1000 0000 rn fx 1001 0000 rn fx 1010 sts mach,rn sts macl,rn sts pr,rn 0000 rn rm 1011 0000 rn rm 11md mov.b @(r0,rm),rn mov.w @(r0,rm),rn mov.l @(r0,rm),rn 0001 rn rm disp mov.l rm,@(disp:4,rn) 0010 rn rm 00md mov.b rm,@rn mov.w rm,@rn mov.l rm,@rn 0010 rn rm 01md mov.b rm,@-rn mov.w rm,@-rn mov.l rm,@-rn div0s rm,rn 0010 rn rm 10md tst rm,rn and rm,rn xor rm,rn or rm,rn 0010 rn rm 11md cmp/str rm,rn xtrct rm,rn mulu rm,rn muls rm,rn 0011 rn rm 00md cmp/eq rm,rn cmp/hs rm,rn cmp/ge rm,rn 0011 rn rm 01md div1 rm,rn cmp/hi rm,rn cmp/gt rm,rn 0011 rn rm 10md sub rm,rn subc rm,rn subv rm,rn 0011 rn rm 11md add rm,rn addc rm,rn addv rm,rn 0100 rn fx 0000 shll rn shal rn 0100 rn fx 0001 shlr rn cmp/pz rn shar rn 0100 rn fx 0010 sts.l mach, @?n sts.l macl, @?n sts.l pr, @?n
40 hitachi table 2.18 operation code map (cont) instruction code fx: 0000 fx: 0001 fx: 0010 fx: 0011?111 msb lsb md: 00 md: 01 md: 10 md: 11 0100 rn fx 0011 stc.l sr,@?n stc.l gbr,@?n stc.l vbr,@?n 0100 rn fx 0100 rotl rn rotcl rn 0100 rn fx 0101 rotr rn cmp/pl rn rotcr rn 0100 rm fx 0110 lds.l @rm+,mach lds.l @rm+,macl lds.l @rm+,pr 0100 rm fx 0111 ldc.l @rm+,sr ldc.l @rm+,gbr ldc.l @rm+,vbr 0100 rn fx 1000 shll2 rn shll8 rn shll16 rn 0100 rn fx 1001 shlr2 rn shlr8 rn shll16 rn 0100 rm fx 1010 lds rm,mach lds rm,macl lds rm,pr 0100 rm/rn fx 1011 jsr @rm tas.b @rn jmp @rm 0100 rm fx 1100 0100 rm fx 1101 0100 rn fx 1110 ldc rm,sr ldc rm,gbr ldc rm,vbr 0100 rn rm 1111 mac.w @rm+,@rn+ 0101 rn rm disp mov.l @(disp:4,rm),rn 0110 rn rm 00md mov.b @rm,rn mov.w @rm,rn mov.l @rm,rn mov rm,rn 0110 rn rm 01md mov.b @rm+,rn mov.w @rm+,rn mov.l @rm+,rn not rm,rn 0110 rn rm 10md swap.b @rm+,rn swap.w @rm+,rn negc rm,rn neg rm,rn 0110 rn rm 11md extu.b rm,rn extu.w rm,rn exts.b rm,rn exts.w rm,rn 0111 rn imm add #imm:8,rn 1000 00md rn disp mov.b r0, @(disp:4,rn) mov.w r0, @(disp:4,rn) 1000 01md rm disp mov.b @(disp:4, rm),r0 mov.w r0, @(disp:4, rn),r0 1000 10md imm/disp cmp/eq #imm:8,r0 bt disp:8 bf disp:8 1000 11md imm/disp 1001 rn disp mov.w @(disp:8,pc),rn 1010 disp bra disp:12 1011 disp bsr disp:12
hitachi 41 table 2.18 operation code map (cont) instruction code fx: 0000 fx: 0001 fx: 0010 fx: 0011?111 msb lsb md: 00 md: 01 md: 10 md: 11 1100 00md imm/disp mov.b r0,@ (disp:8,gbr) mov.w r0,@ (disp:8,gbr) mov.l r0,@ (disp:8,gbr) trapa #imm:8 1100 01md disp mov.b @(disp:8, gbr),r0 mov.w @(disp:8, gbr),r0 mov.l @(disp:8, gbr),r0 mova @(disp:8, pc),r0 1100 10md imm tst #imm:8,r0 and #imm:8,r0 xor #imm:8,r0 or #imm:8,r0 1100 11md imm tst.b #imm:8, @(r0,gbr) and.b #imm:8, @(r0,gbr) xor.b #imm:8, @(r0,gbr) or.b #imm:8, @(r0,gbr) 1101 rn disp mov.l @(disp:8,pc),rn 1110 rn imm mov #imm:8,rn 1111 ... 2.5 cpu state 2.5.1 state transitions the cpu has five processing states: reset, exception processing, bus release, program execution and power-down. the transitions between the states are shown in figure 2.6. for more information on the reset and exception processing states, see section 4, exception processing. for details on the power-down states, see section 19, power down states.
42 hitachi res = 0, nmi = 1 res = 0, nmi = 0 power-on reset state manual reset state sleep mode standby mode program execution state bus release state exception processing state res = 1, nmi = 0 res = 1, nmi = 1 when an interrupt source or dma address error occurs nmi interrupt source occurs exception processing ends bus request generated exception processing source occurs bus request cleared bus request generated bus request cleared sby bit cleared for sleep instruction sby bit set for sleep instruction from any state when res = 0 and nmi = 1 from any state when res = 0 and nmi = 0 reset states power-down state bus request generated bus request cleared figure 2.6 transitions between processing states reset state: in the reset state the cpu is reset. this occurs when the res pin level goes low. when the nmi pin is high, the result is a power-on reset; when it is low, a manual reset will occur.when turning on the power, make sure to carry out a power-on reset.
hitachi 43 on a power-on reset, all cpu internal states and on-chip peripheral module registers are initialized. in a manual reset, all cpu internal states and on-chip peripheral module registers, with the exception of the bus state controller (bsc) and pin function controller (pfc), are initialized. on a manual reset, the bsc is not initialized, so the refresh operation will continue. exception processing state: exception processing is a transient state that occurs when the cpu? processing state flow is altered by exception processing sources such as resets or interrupts. for a reset, the initial values of the program counter pc (execution start address) and stack pointer sp are fetched from the exception processing vector table and stored; the cpu then branches to the execution start address and execution of the program begins. for an interrupt, the stack pointer (sp) is accessed and the program counter (pc) and status register (sr) are saved to the stack area. the exception service routine start address is fetched from the exception processing vector table; the cpu then branches to that address and the program starts executing, thereby entering the program execution state. program execution state: in the program execution state, the cpu sequentially executes the program. power-down state: in the power-down state, the cpu operation halts and power consumption declines. the sleep instruction places the cpu in the power-down state. this state has two modes: sleep mode and standby mode. this is described in more detail in section 2.5.1, power- down state. bus release state: in the bus release state, the cpu releases rights to the bus to the device that has requested them. 2.5.2 power-down state in addition to the ordinary program execution states, the cpu also has a power-down state in which cpu operation halts and power consumption is lowered. there are two power-down state modes: sleep mode and standby mode. sleep mode: when the standby bit sby (in the standby control register sbycr) is cleared to 0 and a sleep instruction executed, the cpu moves from program execution state to sleep mode. in the sleep mode, the cpu halts and the contents of its internal registers and the data in on-chip ram are stored. the on-chip peripheral modules other than the cpu do not halt in the sleep mode. to return from sleep mode, use a reset, any interrupt, or a dma address error; the cpu returns to ordinary program execution state through the exception processing state.
44 hitachi software standby mode: to enter the standby mode, set the standby bit sby (in the standby control register sbycr) to 1 and execute a sleep instruction. in standby mode, all cpu, on-chip peripheral module and oscillator functions are halted. cpu internal register contents and on-chip ram data are held. to return from standby mode, use a reset or an external nmi interrupt. for resets, the cpu returns to ordinary program execution state through the exception processing state when placed in a reset state during oscillator stabilization time. for nmi interrupts, the cpu returns to ordinary program execution state through the exception processing state after the oscillator stabilization time has elapsed. in this mode, power consumption drops markedly, since the oscillator stops. table 2.19 power-down state state mode conditions clock cpu on-chip peripheral modules cpu regi- sters ram i/o ports canceling sleep mode execute sleep instruction with sby bit cleared to 0 in sbycr run halt run held held held 1. interrupt 2. dma address error 3. power-on reset 4. manual reset stand by mode execute sleep instruction with sby bit set to 1 in sbycr halt halt halt and initialize* held held held or high-z* (selectable) 1. nmi 2. power-on reset 3. manual reset note: differs depending on the peripheral module and pin.
hitachi 45 section 3 operating modes 3.1 types of operating modes and their selection the sh7020 and sh7021 operate in one of four operating modes (modes 0, 1, 2, and 7). modes 0 and 1 differ in the bus width of memory area 0. the mode is selected by the mode pins (md2e md0) as indicated in table 3.1. do not change the mode selection while the chip is operating. table 3.1 operating mode selection pin settings operating mode md2 md1 md0 mode name bus width of area 0 mode 0 * 2 0 0 0 mcu mode 0 8 bits mode 1 * 2 0 0 1 mcu mode 1 16 bits mode 2 0 1 0 mcu mode 2 on-chip rom mode 7* 1 1 1 prom mode notes : 1.sh7021 prom version only 2.only modes 0 and 1are available in the sh7020 romless version. 3.2 operating mode descriptions 3.2.1 mode 0 (mcu mode 0) in mode 0, memory area 0 has an eight-bit bus width. for the memory map, see section 8, bus state controller. 3.2.2 mode 1 (mcu mode 1) in mode 1, memory area 0 has a 16-bit bus width. 3.2.3 mode 2 (mcu mode 2) in mode 2, memory area 0 is assigned to the on-chip rom. 3.2.4 mode 7 (prom mode) mode 7 is a prom mode. in this mode, the eprom can be programmed.for details,see section 16, rom. do not set to mode 7 unless the product is the sh7021(prom version).
hitachi 47 section 4 exception processing 4.1 overview 4.1.1 exception processing types and priorities as figure 4.1 indicates, exception processing may be caused by a reset, address error, interrupt, or instruction. exception sources are prioritized as indicated in figure 4.1. if two or more exceptions occur simultaneously, they are accepted and processed in the priority order shown.
48 hitachi reset priority high low exception source ?power-on reset ?manual reset address error interrupt ?cpu address error ?dma address error ?nmi ?user break ?irq ?on-chip module ? irq0 e irq7 direct memory access controller 16-bit integrated-timer pulse unit serial communications interface parity control unit (part of the bus con- troller) watchdog timer dram refresh control unit (part of the bus controller) instruction trap instruction illegal slot instruction general illegal instruction trapa instruction undefined instruction or instruction that rewrites the pc* 1 placed directly after a delayed branch instruction* 2 undefined code notes: 1. the instructions that rewrite the pc are jmp, jsr, bra, bsr, rts, rte, bt, bf, and trapa. 2. the delayed branch instructions are jmp, jsr. bra. bsr, rts, and rte. figure 4.1 exception source types and priority
hitachi 49 4.1.2 exception processing operation exception sources are detected at the times indicated in table 4.1, whereupon processing starts. table 4.1 exception source detection and time of the start of processing exception type source detection and time of the start of processing reset power-on low-to-high transition at pin res when nmi is high manual low-to-high transition at pin res when nmi is low address error detected when instruction is decoded and starts after the instruction that was executing prior to this point is completed. interrupt detected when instruction is decoded and starts after the instruction that was executing prior to this point is completed. instruction trap instruction starts when a trap instruction (trapa) is executed. general illegal instruction starts when undefined code is decoded at a position other than directly after a delayed branch instruction (a delay slot). illegal slot instruction starts when undefined code or an instruction that rewrites the pc is decoded directly after a delayed branch instruction (in a delay slot). when exception processing begins, the cpu operates as follows: resets: the initial values of the program counter (pc) and stack pointer (sp) are read from the exception vector table (the respective pc and sp values are h'00000000 and h'00000004 for a power-on reset and h'00000008 and h'0000000c for a manual reset). for more information on the exception vector table, see section 4.1.3, exception vector table. next, the vector base register (vbr) is cleared to zero and interrupt mask bits (i3?0) in the status register (sr) are set to 1111. program execution starts from the pc address read from the exception vector table. address errors, interrupts and instructions: sr and pc are pushed onto the stack indicated in r15. for interrupts, the interrupt priority level is written in the interrupt mask bits (i3?0). for address errors and instructions, bits i3?0 are not affected. next, the start address is fetched from the exception vector table, and program execution starts from this address. 4.1.3 exception process vector table before exception processing can execute, the exception vector table must be set in memory. the exception processing vector table holds the start addresses of exception service routines (the table for reset exception processing stores initial pc and sp values). different vector numbers and vector table address offsets are assigned to different exception sources. the vector table addresses are calculated from the corresponding vector numbers and vector address offsets. in exception processing, the exception service routine start address is fetched from the exception vector table indicated by this vector table address.
50 hitachi table 4.2 lists vector numbers and vector table address offsets. table 4.3 shows how to calculate vector table addresses. table 4.2 exception process vector table exception source vector number vector table address offset power-on reset pc 0 h'00000000?'00000003 sp 1 h'00000004?'00000007 manual reset pc 2 h'00000008?'0000000b sp 3 h'0000000c?'0000000f general illegal instruction 4 h'00000010?'00000013 (reserved for system use) 5 h'00000014?'00000017 illegal slot instruction 6 h'00000018?'0000001b (reserved for system use) 7 h'0000001c?'0000001f 8 h'00000020?'00000023 cpu address error 9 h'00000024?'00000027 dma address error 10 h'00000028?'0000002b interrupts nmi 11 h'0000002c?'0000002f user break 12 h'00000030?'00000033 (reserved for system use) 13?1 h'00000034?'00000037 to h'0000007c h'0000007f trap instruction (user vectors) 32?3 h'00000080?'00000083 to h'000000fc h'000000ff interrupts irq0 64 h'00000100?'00000103 irq1 65 h'00000104?'00000107 irq2 66 h'00000108?'0000010b irq3 67 h'0000010c?'0000010f irq4 68 h'00000110?'00000113 irq5 69 h'00000114?'00000117 irq6 70 h'00000118?'0000011b irq7 71 h'0000011c?'0000011f on-chip modules* 72?55 h'00000120?'00000123 to h'000003fc h'000003ff note: see table 5.3, interrupt exception processing vectors and rankings, in section 5, interrupt controller, for details on vector numbers and vector table address offsets of individual on- chip peripheral module interrupts.
hitachi 51 table 4.3 calculation of exception vector table addresses exception source calculation of vector table addresses reset (vector table address) = (vector table address offset) = (vector number) 4 address error, interrupt, instructions (vector table address) = vbr + (vector table address offset) = vbr + (vector number) 4 note: vbr: vector base register. for vector table address offsets and vector numbers, see table 4.2. 4.2 reset 4.2.1 reset types a reset is the highest-priority exception. there are two types of reset: power-on reset and manual reset. as table 4.4 shows, a power-on reset initializes the internal state of the cpu and all registers of the on-chip peripheral modules. a manual reset initializes the internal state of the cpu and all registers of the on-chip peripheral modules except the bus state controller (bsc), pin function controller (pfc) and i/o ports (i/o). table 4.4 reset types transition conditions internal state reset nmi res cpu on-chip peripheral module power-on reset high low initialize initialize manual reset low low initialize initialize all except bsc, pfc and i/o 4.2.2 power-on reset when the nmi pin is high, a low input at the res pin drives the chip into the power-on reset state. the res pin should be driven low while the clock pulse generator (cpg) is stopped (or while the cpg is operating during the oscillation settling time) for at least 20 t cyc to assure that the lsi is reset. a power-on reset initializes the internal state of the cpu and all registers of the on-chip peripheral modules. for pin states in the power-on reset state, see appendix b, pin states. while the nmi pin remains high, if the res pin is held low for a certain time then driven high in the power-on state, power-on reset exception processing begins. the cpu then: 1. reads the start address (initial pc value) from the exception vector table. 2. reads the initial stack pointer value (sp) from the exception vector table.
52 hitachi 3. clears the vector base register (vbr) to h'00000000, and sets interrupt mask bits i3?0 in the status register (sr) to h'f (1111). 4. loads the values read from the exception vector table into pc and sp and starts program execution. further, make sure to carry out a power-on reset when turning on the power of the system. 4.2.3 manual reset when the nmi pin is high, a low input at the res pin drives the chip into the manual reset state. to be assured of resetting the lsi, drive the res pin low for at least 20 t cyc . a manual reset initializes the internal state of the cpu and all registers of the on-chip peripheral modules except the bus state controller, pin function controller and i/o ports. since a manual reset does not affect the bus state controller, the dram refresh control function operates even if the manual reset state continues for a long time. when a manual reset is performed during the bus cycle, the manual reset exception processing waits for the end of the bus cycle before beginning. the manual reset thus cannot be used to abort the bus cycle. for the pin states during the manual reset state, see appendix b, pin states. while the nmi pin remains low, if the res pin is held low for a certain time then driven high in the manual reset state, manual reset exception processing begins. the cpu carries out the same operations as for a power-on reset. 4.3 address errors 4.3.1 address error sources address errors occur during instruction fetches and data reading/writing as shown in table 4.5.
hitachi 53 table 4.5 address error sources bus cycle type bus master operation address error instruction fetch cpu instruction fetch from even address none (normal) instruction fetch from odd address address error instruction fetch from outside on-chip peripheral module space none (normal) instruction fetch from on-chip peripheral module space address error data read/write cpu or dmac access to word data from even address none (normal) access to word data from odd address address error access to long word data aligned on long word boundary none (normal) access to long word data not aligned on long?ord boundary address error access to word or byte data in on-chip peripheral module space* none (normal) access to long word data in 16-bit on-chip peripheral module space* none (normal) access to long word data in 8-bit on-chip peripheral module space* address error note: see section 8, bus state controller, for details on the on-chip peripheral module space. 4.3.2 address error exception processing when an address error occurs, address error exception processing starts after both the bus cycle that caused the address error and the instructions that were being executed at that time have been completed. the cpu then: 1. pushes the sr onto the stack. 2. pushes the program counter onto the stack. the pc value saved is the top address of the instruction following the last instruction to be executed. 3. fetches the exception service routine start address from the exception vector table for the address error that occurred and starts program execution from that address. the branch that occurs here is not a delayed branch.
54 hitachi 4.4 interrupts 4.4.1 interrupt sources table 4.6 lists the types of interrupt exception processing sources (nmi, user break, irq, on-chip peripheral module). table 4.6 interrupt sources interrupt requesting pin or module number of sources nmi nmi pin (external input) 1 user break user break controller 1 irq irq0 irq7 pin (external input) 8 on-chip direct memory access controller 4 16-bit integrated-timer pulse unit 15 serial communications interface 8 watchdog timer 1 bus state controller 2 each interrupt source has a different vector number and vector address offset value. see table 5.3, interrupt exception vectors and rankings, in section 5, interrupt controller, for details on vector numbers and vector table address offsets. 4.4.2 interrupt priority rankings interrupt sources are assigned priorities. when multiple interrupts occur at the same time, the interrupt controller (intc) ascertains their priorities and starts exception processing based on its findings. priorities from 16? can be assigned, with 0 the lowest level and 16 the highest. the nmi has priority level 16 and cannot be masked. nmi is always accepted. the user break priority level is 15. the irq and on-chip peripheral module interrupt priority levels can be set in interrupt priority level registers a? (ipra?pre) as shown in table 4.7. priority levels 0?5 can be set. see section 5.3.1, interrupt priority level registers a? (ipra?pre), for details. table 4.7 interrupt priority rankings type priority comments nmi 16 fixed and unmaskable user break 15 fixed irq and on-chip peripheral modules 0?5 set in interrupt priority level registers a? (ipra?pre)
hitachi 55 4.4.3 interrupt exception processing when an interrupt is generated, the intc ascertains the interrupt rankings. nmi is always accepted, but other interrupts are only accepted if their ranking is higher than the ranking set in the interrupt mask bits (i3?0) of the sr. when an interrupt is accepted, interrupt exception processing begins. in the interrupt exception processing sequence, the sr and pc are pushed onto the stack, and the priority level of the accepted interrupt is copied to the interrupt mask level bits (i3?0) in the sr. in nmi exception processing, the priority ranking is 16 but the value 15 (h'f) is stored in i3?0. the exception service routine start address for the accepted interrupt is fetched from the exception vector table and the program branches to that address and starts executing. for further information on interrupts, see section 5.4, interrupt operation. 4.5 instruction exceptions 4.5.1 types of instruction exceptions table 4.8 shows the three types of instruction that start exception processing (trap instructions, illegal slot instructions, and general illegal instructions). table 4.8 types of instruction exceptions type source instruction comments trap instruction trapa illegal slot instruction undefined code or instruction that rewrites the pc located immediately after a delayed branch instruction (delay slot) delayed branch instructions are: jmp, jsr, bra, bsr, rts, rte. instructions that rewrite the pc are: jmp, jsr, bra, bsr, rts, rte, bt, bf and trapa general illegal instructions undefined code in other than delayed slot 4.5.2 trap instruction trap instruction exception processing is carried out when a trap instruction (trapa) is executed. the cpu then: 1. saves the status register by pushing register contents onto the stack. 2. pushes the program counter value onto the stack. the pc value saved is the top address of the next instruction after the trapa instruction. 3. reads an exception processing service routine start address from the vector table corresponding to a vector number specified in the trapa instruction, branches to that address, and starts program execution. the branch is not a delayed branch.
56 hitachi 4.5.3 illegal slot instruction an instruction located immediately after a delayed branch instruction is called an ?nstruction placed in a delay slot.?if an undefined instruction is located in a delay slot, illegal slot instruction exception processing begins executing when the undefined code is decoded. illegal slot instruction exception processing also begins when the instruction located in the delay slot is an instruction that rewrites the program counter. in this case, exception processing begins when the instruction that rewrites the pc is decoded. the cpu performs illegal slot exception processing as follows: 1. saves the status register onto the stack. 2. pushes the program counter value onto the stack. the pc value saved is the branch destination address of the delayed branch instruction immediately before the instruction that contains the undefined code or rewrites the pc. 3. fetches an exception processing service routine start address from the vector table corresponding to the exception that occurred, branches to that address and the program starts executing. the branch is not a delayed branch. 4.5.4 general illegal instructions if an undefined instruction located other than a delay slot (immediately after a delayed branch instruction) is decoded, general illegal instruction exception processing is executed. the cpu follows the same procedure as for illegal slot exception processing, except that the program counter (pc) value pushed on the stack in general illegal instruction exception processing is the top address of the illegal instruction with the undefined code.
hitachi 57 4.6 cases in which exceptions are not accepted in some cases, address errors and interrupts that directly follow a delayed branch instruction or interrupt-disabled instruction are not accepted immediately. table 4.9 lists these cases. when this occurs, the exception is accepted when an instruction that can accept the exception is decoded. table 4.9 cases in which exceptions are not accepted exception source case address error interrupt immediately after delayed branch instruction* 1 xx immediately after interrupt-disabled instruction* 2 ox x: not accepted o: accepted notes: 1. delayed branch instructions: jmp, jsr, bra, bsr, rts, rte 2. interrupt-disabled instructions: ldc, ldc.l, stc, stc.l, lds, lds.l, sts, sts.l 4.6.1 immediately after delayed branch instructions address errors and interrupts are not accepted when an instruction in a delay slot immediately following a delayed branch instruction is decoded. the delayed branch instruction and the instruction in the delay slot are therefore always executed one after the other. exception processing is never inserted between them. 4.6.2 immediately after interrupt-disabling instructions interrupts are not accepted when the instruction immediately following an interrupt-disabled instruction is decoded. address errors are accepted, however.
58 hitachi 4.7 stack status after exception processing table 4.10 shows the stack after exception processing. table 4.10 stack after exception processing type stack status type stack status address error upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr address of instruction after instruc- tion that has finished executing sp interrupt upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr address of instruction after instruc- tion that has finished executing sp trap instruc- tion upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr address of instruction after trapa instruction sp illegal slot instruc- tion upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr branch destination address of delayed branch instuction sp general illegal instruc- tion upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr start add- ress of illegal instruction sp note: stack status is based on a bus width of 16 bits.
hitachi 59 4.8 notes 4.8.1 value of the stack pointer (sp) an address error occurs if the stack is accessed for exception processing when the value of the stack pointer (sp) is not a multiple of four. therefore, a multiple of four should always be stored in sp. 4.8.2 value of the vector base register (vbr) an address error occurs if the vector table is accessed for exception processing when the value of the vector base register (vbr) is not a multiple of four. therefore, vbr should always be set to a multiple of four. 4.8.3 address errors that are caused by stacking during address error exception processing when the stack pointer is not a multiple of four, address errors will occur in the exception processing (interrupt, etc.) stacking. after the exception processing ends, the cpu will then shift to address error exception processing. an address error will also occur during the address error exception processing stacking, but the cpu is set up to ignore the address error so that it can avoid an infinite series of address errors. this allows it to shift program control to the address error exception service routine and process the error. when an address error does occur in exception processing stacking, the stacking bus cycle (write) is executed. in sr and pc stacking, four is subtracted from each of the sps so the sp values are not multiples of four after stacking either. since the address value output during stacking is the sp value, the address that produced the error is exactly what is output. in such cases, the stacked write data will be undefined.
hitachi 61 section 5 interrupt controller (intc) 5.1 overview the interrupt controller (intc) determines the priority of interrupt sources and controls interrupt requests to the cpu. intc has registers for assigning priority levels to interrupt sources. these registers handle interrupt requests according to user-established priorities. 5.1.1 features the interrupt controller has the following features: 16 settable priority levels: five interrupt priority registers can set 16 levels of interrupt priorities for irq and on-chip peripheral interrupt sources. the intc has an nmi input level t bit that indicates nmi pin status. by reading this bit with the interrupt exception service routine, the pin status can be checked for use in a noise canceller function. the interrupt controller can notify external devices (via the irqout pin) that an onchip interrupt has been occured. in this way an external device can, for example, be informed if an on-chip interrupt occurs while the chip is operating in a bus-released mode and the bus has been requested. 5.1.2 block diagram figure 5.1 is a block diagram of the interrupt controller.
62 hitachi cpu sr interrupt request com- parator priority decision logic input control (interrupt request) (interrupt request) (interrupt request) (interrupt request) (interrupt request) (interrupt request) (interrupt request) icr ipr ipra?pre module bus bus interface internal bus i3 i2 i1 i0 intc irqout nmi irq0 irq1 irq2 irq3 irq4 irq5 irq6 irq7 ubc dmac itu sci prt wdt ref ubc: user break controller wdt: watchdog timer dmac: direct memory access controller ref: dram refresh control unit of bsc itu: 16-bit integrated-timer pulse unit icr: interrupt control register sci: serial communications interface ipra?pre: interrupt priority registers a? prt: parity control unit of bsc sr: status register figure 5.1 block diagram of the interrupt controller
hitachi 63 5.1.3 pin configuration intc pins are summarized in table 5.1. table 5.1 intc pin configuration name abbr. i/o function nonmaskable interrupt input pin nmi i inputs a non-maskable interrupt request signal interrupt request input pins irq0 irq7 i inputs maskable interrupt request signals interrupt request output pin irqout o outputs a signal indicating an interrupt source has occurred. 5.1.4 registers the interrupt controller has six registers as listed in table 5.2. these registers are used for setting interrupt priority levels and controlling the detection of external interrupt input signals. table 5.2 interrupt controller register configuration name abbr. r/w address* 2 initial value bus width interrupt priority register a ipra r/w h'5ffff84 h'0000 8, 16, 32 interrupt priority register b iprb r/w h'5ffff86 h'0000 8, 16, 32 interrupt priority register c iprc r/w h'5ffff88 h'0000 8, 16, 32 interrupt priority register d iprd r/w h'5ffff8a h'0000 8, 16, 32 interrupt priority register e ipre r/w h'5ffff8c h'0000 8, 16, 32 interrupt control register icr r/w h'5ffff8e *1 8, 16, 32 note: 1. h'8000 when pin nmi is high, h'0000 when pin nmi is low. 2. only the values of bits a27?24 and a8?0 are valid; bits a23?9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 5.2 interrupt sources there are four types of interrupt sources: nmi, user break, irq, and on-chip peripheral module interrupts. interrupt rankings are expressed as priority levels (0?6), with 0 the lowest and 16 the highest. an interrupt set to level 0 is masked.
64 hitachi 5.2.1 nmi interrupts nmi is the highest-priority interrupt (level 16) and is always accepted. input at the nmi pin is edge-sensed. either the rising or falling edge can be selected by setting the nmi edge select bit (nmie) in the interrupt control register (icr). nmi interrupt exception processing sets the interrupt mask level bits (i3?0) in the status register (sr) to level 15. 5.2.2 user break interrupt a user break interrupt occurs when a break condition is satisfied in the user break controller (ubc). a user break interrupt has priority level 15. user break interrupt exception processing sets the interrupt mask level bits (i3?0) in the status register (sr) to level 15. for further details about the user break interrupt, see section 6, user break controller. 5.2.3 irq interrupts irq interrupts are requested by input from pins irq0 - irq7 . irq sense select bits 0e7 (irq0se irq7s) in the interrupt control register (icr) can select low-level sensing or falling-edge sensing for each pin independently. interrupt priority registers a and b (ipra and iprb) can select priority levels from 0e15 for each pin. irq interrupt exception processing sets the interrupt mask level bits (i3ei0) in the status register (sr) to the priority level value of the irq interrupt that was accepted. 5.2.4 on-chip interrupts on-chip interrupts are interrupts generated by the following 5 on-chip peripheral modules: direct memory access controller (dmac) 16-bit integrated-timer pulse unit (itu) serial communications interface (sci) bus state controller (bsc) watchdog timer (wdt) a different interrupt vector is assigned to each interrupt source, so the exception service routine does not have to decide which interrupt has occurred. priority levels 0e15 can be assigned to individual on-chip peripheral module in interrupt priority registers cee (iprceipre). on-chip interrupt exception processing sets the interrupt mask level bits (i3ei0) in the status register (sr) to the priority level value of the on-chip interrupt that was accepted.
hitachi 65 5.2.5 interrupt exception vectors and priority rankings table 5.3 lists the vector numbers, vector table address offsets, and interrupt priority order of the interrupt sources. each interrupt source is allocated a different vector number and vector table address offset. the vector table address is calculated from this vector number and address offset. in interrupt exception processing, the exception service routine start address is fetched from the vector table indicated by this vector table address. see table 4.3, calculation of exception vector table addresses, in section 4, exception processing, for details on this calculation. arbitrary interrupt priority levels between 0 and 15 can be assigned to irq and on-chip peripheral module interrupt sources by setting interrupt priority registers a? (ipra?pre) for each pin or module. the interrupt sources for iprc?pre, however, must be ranked in the order listed under priority within module in table 5.3 and cannot be changed. a reset assigns priority level 0 to irq and on-chip peripheral module interrupts. if the same priority level is assigned to two or more interrupt sources, and interrupts from those sources occur simultaneously, their priority order is the default priority order indicated at the right in table 5.3.
66 hitachi table 5.3 interrupt exception vectors and rankings interrupt source interrupt pri- ority order (initial value) ipr (bit numbers) priority within module vec- tor no. address offset in vector table default priority order nmi 16 11 h'0000002c?'0000002f high user break 15 12 h'00000030?'00000033 irq0 0?5 (0) ipra (15?2) 64 h'00000100?'00000103 irq1 0?5 (0) ipra (11?) 65 h'00000104?'00000107 irq2 0?5 (0) ipra (7?) 66 h'00000108?'0000010b irq3 0?5 (0) ipra (3?) 67 h'0000010c?'0000010f irq4 0?5 (0) iprb (15?2) 68 h'00000110?'00000113 irq5 0?5 (0) iprb (11?) 69 h'00000114?'00000117 irq6 0?5 (0) iprb (7?) 70 h'00000118?'0000011b irq7 0?5 (0) iprb (3?) 71 h'0000011c?'0000011f dmac0 dei0 0?5 (0) iprc (15?2) 3 72 h'00000120?'00000123 reserved 2 73 h'00000124?'00000127 dmac1 dei1 1 74 h'00000128?'0000012b reserved 0 75 h'0000012c?'0000012f dmac2 dei2 0?5 (0) iprc (11?) 3 76 h'00000130?'00000133 reserved 2 77 h'00000134?'00000137 dmac3 dei3 1 78 h'00000138?'0000013b reserved 0 79 h'0000013c?'0000013f itu0 imia0 0?5 (0) iprc (7?) 3 80 h'00000140?'00000143 imib0 2 81 h'00000144?'00000147 ovi0 1 82 h'00000148?'0000014b reserved 0 83 h'0000014c?'0000014f itu1 imia1 0?5 (0) iprc (3?) 3 84 h'00000150?'00000153 imib1 2 85 h'00000154?'00000157 ovi1 1 86 h'00000158?'0000015b reserved 0 87 h'0000015c?'0000015f itu2 imia2 0?5 (0) iprd (15?2) 3 88 h'00000160?'00000163 imib2 2 89 h'00000164?'00000167 ovi2 1 90 h'00000168?'0000016b reserved 0 91 h'0000016c?'0000016f
hitachi 67 table 5.3 interrupt exception vectors and rankings (cont) interrupt source interrupt pri- ority order (initial value) ipr (bit numbers) priority within module vec- tor no. address offset in vector table default priority order itu3 imia3 0?5 (0) iprd (11?) 3 92 h'00000170?'00000173 imib3 2 93 h'00000174?'00000177 _ ovi3 1 94 h'00000178?'0000017b reserved 0 95 h'0000017c?'0000017f itu4 imia4 0?5 (0) iprd (7?) 3 96 h'00000180?'00000183 imib4 2 97 h'00000184?'00000187 ovi4 1 98 h'00000188?'0000018b reserved 0 99 h'0000018c?'0000018f sci0 eri0 0?5 (0) iprd (3?) 3 100 h'00000190?'00000193 rxi0 2 101 h'00000194?'00000197 txi0 1 102 h'00000198?'0000019b tei0 0 103 h'0000019c?'0000019f sci1 eri1 0?5 (0) ipre (15?2) 3 104 h'000001a0?'000001a3 rxi1 2 105 h'000001a4?'000001a7 txi1 1 106 h'000001a8?'000001ab tei1 0 107 h'000001ac?'000001af prt* 1 pei 0?5 (0) ipre (11?) 3 108 h'000001b0?'000001b3 reserved 2 109 h'000001b4?'000001b7 reserved 1 110 h'000001b8?'000001bb reserved 0 111 h'000001bc?'000001bf wdt iti 0?5 (0) ipre (7?) 3 112 h'000001c0?'000001c3 ref* 2 cmi 2 113 h'000001c4?'000001c7 reserved 1 114 h'000001c8?'000001cb reserved 0 115 h'000001cc?'000001cf reserved 116 to 255 h'000001d0?'000001d3 to h'000003fc?'000003ff low notes: 1. prt: parity control unit of bus state controller. 2. ref: dram refresh control unit of bus state controller.
68 hitachi 5.3 register descriptions 5.3.1 interrupt priority registers a? (ipra?pre) the five registers from ipra?pre are 16-bit read/write registers that assign priority levels from 0?5 to the irq and on-chip peripheral module interrupt sources. interrupt request sources are mapped onto ipra?pre as shown in table 5.4. bit: 15 14 13 12 11 10 9 8 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w table 5.4 interrupt request sources and ipra?pre register bits 15?2 bits 11? bits 7? bits 3? ipra irq0 irq1 irq2 irq3 iprb irq4 irq5 irq6 irq7 iprc dmac0, dmac1 dmac2, dmac3 itu0 itu1 iprd itu2 itu3 itu4 sci0 ipre sci1 prt* 1 wdt, ref* 2 (reserved)* 3 notes: 1. prt: parity control unit of bus state controller. see section 8, bus state controller, for details. 2. ref: dram refresh control unit of bus controller. see section 8, bus state controller, for details. 3. when read, always 0. always write 0 in reserved bits. as indicated in table 5.4, four irq pins or four groups of on-chip peripheral modules are assigned to each interrupt priority register. the priority levels for the four pins or groups can be set by setting the corresponding 4-bit groups of bits 15e12, bits 11e8, bits 7e4, and bits 3e0 (of iprae ipre) with values in the range of h'0 (0000) to h'f (1111). setting h'0 gives interrupt priority level 0 (the lowest). setting h'f gives level 15 (the highest). when two on-chip peripheral modules are assigned to the same bits (dmac0 and dmac1, or dmac2 and dmac3, or the watchdog timer and dram refresh control unit), those two modules have the same priority. a reset initializes ipraeipre to h'0000. they are not initialized by the standby mode.
hitachi 69 5.3.2 interrupt control register (icr) icr is a 16-bit register that sets the input detection mode of the external interrupt input pins nmi and irq0 e irq7 and indicates the input signal level to the nmi pin. a reset initializes icr but the standby mode does not. bit: 15 14 13 12 11 10 9 8 bit name: nmil nmie initial value: * 0 0 0 0 0 0 0 r/w: r r/w bit: 7 6 5 4 3 2 1 0 bit name: irq0s irq1s irq2s irq3s irq4s irq5s irq6s irq7s initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w note: when nmi input is high: 1; when nmi input is low: 0 bit 15 (nmi input level (nmil)): nmil sets the level of the signal input at the nmi pin. nmil cannot be modified. the nmi input level can be read to determine the nmi pin level. bit 15: nmil description 0 nmi input level is low 1 nmi input level is high bits 14? (reserved): these bits always read as 0. the write value should always be 0. bit 8 (nmi edge select (nmie)): nmie selects whether the falling or rising edge of the interrupt request signal to the nmi pin is sensed. bit 8: nmie description 0 interrupt is requested on falling edge of nmi input (initial value) 1 interrupt is requested on rising edge of nmi input bits 7? (irq0?rq7 sense select (irq0s?rq7s)): irq0?rq7 select whether the falling edge or low level of the irq inputs is sensed at the pins irq0 irq7 . bits 7?: irq0s?rq7s description 0 interrupt is requested when irq input is low (initial value) 1 interrupt is requested on falling edge of irq input
70 hitachi 5.4 interrupt operation 5.4.1 interrupt sequence the sequence of interrupt operations will be explained below. figure 5.2 is a flowchart of the operations up to acceptance of the interrupt. 1. the interrupt request sources send interrupt request signals to the interrupt controller. 2. the interrupt controller selects the highest-priority interrupt in the interrupt requests sent, following the priority order indicated in table 5.3 and the levels set in interrupt priority registers a? (ipra?pre). lower priority interrupts are ignored*. if two interrupts with the same priority level are requested simultaneously or if there are multiple interrupts occurring within a single module, the interrupt with the highest default priority or priority within module as indicated in table 5.3 is selected. 3. the interrupt controller compares the priority level of the selected interrupt request with the interrupt mask level bits (i3?0) in the cpu? status register (sr). if the request priority level is equal to or less than the interrupt mask level, the request is ignored. if the request priority level is higher than the interrupt mask level, the interrupt controller accepts the request and sends an interrupt request signal to the cpu. 4. when the interrupt controller accepts an interrupt request, it drives the pin irqout low. 5. the cpu detects the interrupt request sent from the interrupt controller when it decodes the next instruction to be executed. instead of executing that instruction, the cpu starts interrupt exception processing. 6. in interrupt exception processing, first sr and pc are pushed onto the stack. 7. the priority level of the accepted interrupt is copied to the interrupt mask level bits (i3ei0) in the status register (sr). 8. when the accepted interrupt is level-sensed or from an on-chip peripheral module, the pin irqout returns to the high level. if the accepted interrupt is edge-sensed, the pin irqout returns to the high level when the instruction to be executed by the cpu in (5) is replaced by the interrupt exception processing. if the interrupt controller has accepted another interrupt (of a level higher than the current interrupt), however, the pin irqout remains low. 9. the cpu accesses the exception vector table at the entry for the vector number of the accepted interrupt, reads the start address of the exception service routine, branches to that address, and starts executing the program there. this branch is not delayed. note: a request for an external interrupt (irq) designated as edge-detected is held pending once only. an external interrupt designated as level-detected is held pending as long as the interrupt request continues, but if the request is cleared before the cpu next accepts an interrupt, the interrupt request is regarded as not having been made. interrupt requests from on-chip supporting modules are level requests. when the status flag in a particular module is set, an interrupt is requested. for details, see the descriptions of the individual modules. note that the interrupt request will be continued unless an operation described in "clearing conditions" is performed.
hitachi 71 no yes nmi? no yes user break? no yes level 15 interrupt? no yes i3 to i0 level 14? no yes level 14 interrupt? no yes yes i3 to i0 level 13? no yes level 1 interrupt? no yes i3 to i0 = level 0? no program execution state irqout low *1 pushes sr onto stack pushes pc onto stack irqout high *2 branches to exception service routine interrupt? copies level of accep- tance from i3 to i0 reads exception vector table i3 to i0 : interrupt mask bits of status register notes : *1. irqout is the same signal as the interrupt request signal to the cpu (figure 5.1). the pin irqout return to the high level when the interrupt controller has accepted the interrupt of a level higher than the i3 to i0 bits of the status register in the cpu. *2. if the accepted interrupt is edge-sensed, the pin irqout returns to the high level when the instruction to be executed by the cpu is replaced by the interrupt exception processing (before the status register is saved to the stack ). if the interrupt controller has accepted another interrupt of a level higher than the current interrupt. and has requested the interrupt to the cpu, however, the pin irqout remains low. figure 5.2 flowchart of interrupt operation
72 hitachi 5.4.2 stack after interrupt exception processing figure 5.3 shows the stack after interrupt exception processing. upper 16 bits lower 16 bits upper 16 bits lower 16 bits sr pc* 2 address 4n? 4n? 4n? 4n? 4n sp* 3 notes: 1. bus width is 16 bits. 2. pc stores the top address of the next instruction (return instruction) after the executed instruction. 3. the value of sp must always be a multiple of four. figure 5.3 stack after interrupt exception processing
hitachi 73 5.5 interrupt response time table 5.5 indicates the interrupt response time, which is the time from the occurrence of an interrupt request until the interrupt exception processing starts and fetching of the first instruction of the interrupt service routine begins. figure 5.4 shows the pipeline when an irq interrupt is accepted. table 5.5 interrupt response time number of states item nmi or on-chip interrupt irq notes interrupt priority decision and comparison with sr mask bit 23 wait for completion of sequence currently being executed by cpu x ( 0) the longest sequence is the interrupt or address error exception processing sequence: x = 4 + m1 + m2 + m3 + m4. if an interrupt- masking instruction follows, however, the time may be longer. time from interrupt exception processing (saving pc and sr and fetching vector address) until fetching of first instruction of interrupt service routine starts 5 + m1 + m2 + m3 interrupt total 7 + m1 + m2 + m3 8 + m1 + m2 + m3 response minimum 10 11 0.50?.55 m s at 20 mhz maximum 11 + 2(m1 + m2 + m3) + m4 12 + 2(m1 + m2 + m3) + m4 (m1 = m2 = m3 = m4) 0.90 0.95 m s at 20 mhz notes: m1?4 are the number of states needed for the following memory accesses: m1: sr save cycle (long word write) m2: pc save cycle (long word write) m3: vector address read cycle (long word read) m4: fetch top instruction of interrupt service routine
74 hitachi fde mee mme ee fd f 3 3 interrupt accepted irq m1 m2 1 m3 1 5 + m1 + m2 + m3 instruction (instruction replaced by interrupt exception handling) overrun fetch (edge) (level) interrupt service routine first instruction when m1 = m2 = m3, the interrupt response time is 11 cycles. f (instruction fetch) instruction fetched from memory where program is stored. d (instruction decoding) the fetched instruction is decoded. e (instruction execution) data operations and address calculations are performed according to the decoded results. m (memory access) data in memory is accessed. note: for the interrupt acceptance timing, see table 4.1, exception source detection and exception handling start timing, in section 4.1.2, exception handling operation. irqout figure 5.4 example of pipelining in irq interrupt acceptance 5.6 usage notes when the following operations are performed in the order shown when a pin to which irq input is assigned is designated as a general input pin by the pin function controller (pfc) and inputs a low- level signal, the irq falling edge is detected, and an interrupt request is detected, immediately after the setting in (b) is performed: an interrupt control register (icr) setting is made so that an interrupt is detected at the falling edge of irq. (a) the function of pins to which irq input is assigned is switched from general input to irq input by a pin function controller (pfc) setting. (b) therefore, when switching the pin function from general input pin to irq input, the pin function controller (pfc) setting should be changed to irq input while the pin to which irq input is assigned is high.
hitachi 75 section 6 user break controller (ubc) 6.1 overview the user break controller (ubc) simplifies the debugging of user programs. break conditions are set in the ubc and a user break interrupt request is sent to the cpu in response to the contents of a cpu or dmac bus cycle. this function can implement an effective self-monitoring debugger, enabling a program to be debugged by itself without using a large in-circuit emulator. 6.1.1 features the following break conditions can be set: ? address ? cpu cycle or dma cycle ? instruction fetch or data access ? read or write ? operand size (long word access, word access, or byte access) when break conditions are met, a user break interrupt is generated. a user-created user break interrupt exception routine can then be executed. when a break is set to a cpu instruction fetch, the break occurs just before the fetched instruction. 6.1.2 block diagram figure 6.1 is the block diagram of the user break controller.
76 hitachi internal bus bus interface break condition comparator module bus bbr bamrh barh bamrl barl interrupt request interrupt controller user break interrupt generating circuit ubc barh, barl: break address registers h and l bamrh, bamrl: break address mask registers h and l bbr: break bus cycle register figure 6.1 block diagram of the user break controller 6.1.3 register configuration the user break controller has five registers as listed in table 6.1. these registers are used for setting break conditions.
hitachi 77 table 6.1 user break controller registers name abbr. r/w address* initial value bus width break address register high barh r/w h'5ffff90 h'0000 8, 16, 32 break address register low barl r/w h'5ffff92 h'0000 8, 16, 32 break address mask register high bamrh r/w h'5ffff94 h'0000 8, 16, 32 break address mask register low bamrl r/w h'5ffff96 h'0000 8, 16, 32 break bus cycle register bbr r/w h'5ffff98 h'0000 8, 16, 32 note: only the values of bits a27?24 and a8?0 are valid; bits a23?9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 6.2 register descriptions 6.2.1 break address registers (bar) there are two break address registers?reak address register h (barh) and break address register l (barl)?hat together form a single group. both are 16-bit read/write registers. barh stores the upper bits (bits 31?6) of the address of the break condition. barl stores the lower bits (bits 15?) of the address of the break condition. a reset initializes both barh and barl to h'0000. neither is initialized in standby mode. barh: break address register h. bit: 15 14 13 12 11 10 9 8 bit name: ba31 ba30 ba29 ba28 ba27 ba26 ba25 ba24 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: ba23 ba22 ba21 ba20 ba19 ba18 ba17 ba16 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w barh bits 15? (break address 31?6 (ba31?a16)): ba31?a16 store the upper bit values (bits 31?6) of the address of the break condition.
78 hitachi barl: break address register l. bit: 15 14 13 12 11 10 9 8 bit name: ba15 ba14 ba13 ba12 ba11 ba10 ba9 ba8 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: ba7 ba6 ba5 ba4 ba3 ba2 ba1 ba0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w barl bits 15? (break address 15? (ba15?a0)): ba15?a0 store the lower bit values (bits 15?) of the address of the break condition. 6.2.2 break address mask register (bamr) the two break address mask registers?reak address mask register h (bamrh) and break address mask register l (barml)?ogether form a single group. both are 16-bit read/write registers. bamrh determines which of the bits in the break address set in barh are masked. bamrl determines which of the bits in the break address set in barl are masked. a reset initializes bamrh and barml to h'0000. they are not initialized in the standby mode. bamrh: break address mask register h. bit: 15 14 13 12 11 10 9 8 bit name: bam31 bam30 bam29 bam28 bam27 bam26 bam25 bam24 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: bam23 bam22 bam21 bam20 bam19 bam18 bam17 bam16 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bamrh bits 15? (break address mask 31?6 (bam31?am16)): bam31?am16 specify whether bits ba31?a16 of the break address set in barh are masked or not.
hitachi 79 bamrl: break address mask register l. bit: 15 14 13 12 11 10 9 8 bit name: bam15 bam14 bam13 bam12 bam11 bam10 bam9 bam8 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: bam7 bam6 bam5 bam4 bam3 bam2 bam1 bam0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bamrl bits 15? (break address mask 15? (bam15?am0)): bam15?am0 specify whether bits ba15?a0 of the break address set in barh are masked or not. bits 15?: bamn description 0 break address bit ban is included in the break condition (initial value) 1 break address bit ban is not included in the break condition n = 31? 6.2.3 break bus cycle register (bbr) the break bus cycle register (bbr) is a 16-bit read/write register that selects the following four break conditions: cpu cycle or dma cycle instruction fetch or data access read or write operand size (byte, word, long word). a reset initializes bbr to h'0000. it is not initialized in the standby mode.
80 hitachi bit: 15 14 13 12 11 10 9 8 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: bit: 7 6 5 4 3 2 1 0 bit name: cd1 cd0 id1 id0 rw1 rw0 sz1 sz0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 15? (reserved): these bits always read as 0. the write value should always be 0. bits 7 and 6 (cpu cycle/dma cycle select (cd1 and cd0)): cd1 and cd0 select whether to break on cpu and/or dma bus cycles. bit 7: cd1 bit 6: cd0 description 0 0 no break interrupt occurs (initial value) 1 break only on cpu cycles 1 0 break only on dma cycles 1 break on both cpu and dma cycles bits 5 and 4 (instruction fetch/data access select (id1, id0)): id1, id0 select whether to break on instruction fetch and/or data access bus cycles. bit 5: id1 bit 4: id0 description 0 0 no break interrupt occurs (initial value) 1 break only on instruction fetch cycles 1 0 break only on data access cycles 1 break on both instruction fetch and data access cycles
hitachi 81 bits 3 and 2 (read/write select (rw1, rw0)): rw1, rw0 select whether to break on read and/or write access cycles. bit 3: rw1 bit 2: rw0 description 0 0 no break interrupt occurs (initial value) 1 break only on read cycles 1 0 break only on write cycles 1 break on both read and write cycles bits 1 and 0 (operand size select (sz1, sz0)): sz1, sz0 select bus cycle operand size as a break condition. bit 1: sz1 bit 0: sz0 description 0 0 operand size is not a break condition (initial value) 1 break on byte access 1 0 break on word access 1 break on long word access note: when setting to break on an instruction fetch, set the sz0 bit to 0. all instructions will be considered to be accessed as words (even those instructions in on-chip memory for which two instructions can be fetched simultaneously in a single bus cycle). instruction fetch is by word access and cpu/dmac data access is by the specified operand size. they are not determined by the bus width of the space being accessed. 6.3 operation 6.3.1 flow of the user break operation the flow from setting of break conditions to user break interrupt exception processing is described below. 1. break conditions are set in break address register (bar), break address mask register (bamr), and the break bus cycle register (bbr). set the break address in the bar, the address bits to be masked in the bamr and the type of breaking bus cycle in the bbr. when even one of the bbr groups (cpu cycle/dma cycle select bits (cd1, cd0), instruction fetch/data access select bits (id1, id0), read/write select bits (rw1, rw0)) is set to 00 (no user break interrupt), there will be no user break even when all other conditions are consistent. to use a user break interrupt, set conditions for all three pairs. 2. the ubc checks to see if the set conditions are satisfied, using the system shown in figure 6.2. when the break conditions are satisfied, the ubc sends a user break interrupt request to the interrupt controller.
82 hitachi 3. when receiving the user break interrupt request, the interrupt controller checks its priority level. the user break interrupt has priority level 15, so it is accepted only if the interrupt mask level in bits i3?0 in the status register (sr) is 14 or lower. when the i3?0 bit level is 15, the user break interrupt cannot be accepted but it is held pending until user break interrupt exception processing is carried out. nmi exception processing sets i3?0 to level 15, so a user break cannot occur during the nmi service routine unless the nmi service routine itself begins by reducing i3?0 to level 14 or lower. section 5, interrupt controller, described the handling of priority levels in greater detail. 4. the intc sends a request signal for a user break interrupt to the cpu. when the cpu receives it, it starts user break interrupt exception processing. section 5.4, interrupt operation, describes interrupt exception processing in more detail.
hitachi 83 sz1 sz0 user break interrupt rw1 rw0 id1 id0 cd1 cd0 barh/barl bamrh/bamrl 32 32 32 32 32 internal address bits 31? cpu cycle dma cycle instruction fetch data access read cycle write cycle byte size word size long word size figure 6.2 break condition logic
84 hitachi 6.3.2 break on instruction fetch cycles to on-chip memory on-chip memory (on-chip rom and ram) is always accessed 32 bits each bus cycle. two instructionsare therefore fetched in a bus cycle from on-chip memory . although only a single bus cycle occurs for the two-instruction fetch, a break can be set on either instruction by placing the corresponding address in the break address registers (bar). in other words, to break the second of the two instructions fetched, set its start address in the bar. the break will then occur after the first instruction executes. 6.3.3 program counter (pc) value saved in user break interrupt exception processing break on instruction fetch: the program counter (pc) value saved in user break interrupt exception processing for an instruction fetch is the address set as the break condition. the user break interrupt is generated before the fetched instruction is executed. if a break condition is set on the fetch cycle of a delayed slot instruction immediately following a delayed branch instruction or on the fetch cycle of an instruction that follows an interrupt-disabling instruction, however, the user break interrupt is not accepted immediately, so the instruction is executed. the user break interrupt is not accepted until immediately after that instruction. the pc value that will be saved is the start address of the next instruction that is able to accept the interrupt. break on data access (cpu/dmac): the program counter (pc) value is the top address of the next instruction after the last executed instruction at the time when the user break exception processing is activated. when data access (cpu/dmac) is set as a break condition, the place where the break will occur cannot be specified exactly. the break will occur at the instruction fetched close to where the data access that is to receive the break occurs. 6.4 setting user break conditions cpu instruction fetch bus cycle: register settings: barh = h'0000, barl = h'0404, bbr = h'0054 conditions set: address = h'00000404, bus cycle = cpu, instruction fetch, read (operand size not included in conditions) a user break interrupt will occur immediately before the instruction at address h'00000404. if the instruction at address h'00000402 can accept an interrupt, the user break exception processing will be executed after that instruction is executed. the instruction at h'00000404 will not be executed. the value saved to pc is h'00000404. register settings: barh = h'0015, barl = h'389c, bbr = h'0058 conditions set: address = h'0015389c, bus cycle = cpu, instruction fetch, write (operand size not included in conditions) no user break interrupt occurs, because no instruction fetch cycle is ever a write cycle.
hitachi 85 register settings: barh = h'0003, barl = h'0147, bbr = h'0054 conditions set: address = h'00030147, bus cycle = cpu, instruction fetch, read (operand size not included in conditions) no user break interrupt occurs, because instructions are always fetched from even addresses. if the first fetched address after a branch is odd and a user break is set on this address, however, user break exception processing will be carried out after address error exception processing. cpu data access bus cycle: register settings: barh = h'0012, barl = h'3456, bbr = h'006a conditions set: address = h'00123456, bus cycle = cpu, data access, write, word a user break interrupt occurs when word data is written to address h'00123456. register settings: barh = h'00a8, barl = h'0391, bbr = h'0066 conditions set: address = h'00a80391, bus cycle = cpu, data access, read, word no user break interrupt occurs, because word data access is always to an even address. dma cycle: register setting: barh = h'0076, barl = h'bcdc, bbr = h'00a7 conditions set: address = h'0076bcdc, bus cycle = dma, data access, read, long word a user break interrupt occurs when long word data is read from address h'0076bcdc. register setting: barh = h'0023, barl = h'45c8, bbr = h'0094 conditions set: address = h'002345c8, bus cycle = dma, instruction fetch, read (operand size not included) no user break interrupt occurs, because a dma cycle includes no instruction fetch.
86 hitachi 6.5 notes 6.5.1 on-chip memory instruction fetch two instructions are simultaneously fetched from on-chip memory. if a break condition is set on the second of these two instructions but the contents of the ubc break condition registers are changed so as to alter the break condition immediately after the first of the two instructions is fetched, a user break interrupt will still occur when the second instruction is fetched. 6.5.2 instruction fetch at branches when a conditional branch instruction or trapa instruction causes a branch, instructions are fetched and executed as follows: 1. conditional branch instruction, branch taken: bt, bf instruction fetch cycles: conditional branch fetch next-instruction overrun fetch next- instruction overrun fetch branch destination fetch instruction execution: conditional branch instruction execution branch destination instruction execution 2. trapa instruction, branch taken: trapa instruction fetch cycles: trapa instruction fetch next-instruction overrun fetch next- instruction overrun fetch branch destination fetch instruction execution: trapa instruction execution branch destination instruction execution when a conditional branch instruction or trapa instruction causes a branch, the branch destination will be fetched after the next instruction or the one after that does an overrun fetch. when the next instruction or the one after that is set as a break condition, a branch will result in the generation of a user break interrupt at the next instruction or the instruction after that, neither of which instructions will be executed.
hitachi 87 6.5.3 instruction fetch break if a break is attempted at the task a return destination instruction fetch, task b is activated before the ubc interrupt by interrupt b generated during task a processing, and the ubc interrupt is handled after the interrupt b exception handling. (1) cause the sh7032/sh7034 chip operates as follows. f f de e mee mme ee m mm e e e fd f interrupt b accepted interrupt exception handling interrupt exception handling ubc interrupt accepted
break condition instruction replaced by interrupt exception handling overrun fetch task b first instruction fetch (instruction replaced by interrupt exception handling) (0xf000978 overrun fetch) ubc first instruction fetch 0x00011a0a 0x00011a0c 0xf000974 0x02000030 f figure 6.3 ubc operation it actually takes at least two cycles for the ubc interrupt generated by the address 0x00011a0c instruction fetch cycle to be sent to the interrupt controller and interrupt exception handling to begin. however, as shown in figure 6.3, when the ubc interrupt is generated, previously generated interrupt b initiated by task b is accepted first, and the ubc interrupt is accepted after completion of the interrupt b exception handling. (2) remedy there is no way of preventing this operation by hardware. a software solution, such as the use of a flag, must be employed.
hitachi 89 section 7 clock pulse generator (cpg) 7.1 overview the superh microcomputer has a built-in clock pulse generator (cpg) that supplies the lsi and external devices with a clock pulse. the cpg makes the lsi run at the oscillation frequency of the crystal resonator. the cpg consists of an oscillator and a duty cycle correcting circuit (figure 7.1). the cpg can be made to generate a clock signal by connecting it to a crystal resonator or by inputting an external clock. (the cpg is halted in standby mode.) xtal extal ck system clock oscillator duty correcting circuit internal clock ( f ) cpg figure 7.1 block diagram of the clock pulse generator 7.2 clock source clock pulses can be supplied from a connected crystal resonator or an external clock. 7.2.1 connecting a crystal resonator circuit configuration: a crystal resonator can be connected as shown in figure 7.2. use the damping resistance rd shown in table 7.1. use an at-cut parallel resonating crystal with a frequency equal to the system clock (ck) frequency. connect load capacitors (c l1 and c l2 ) as shown in the figure. the clock pulse produced by the crystal resonator and internal pulse generator is sent to the duty cycle correction circuit where its duty cycle is corrected. it is then supplied to the lsi and to external devices.
90 hitachi xtal extal c l1 = c l2 = ic?2 pf c l1 c l2 rd figure 7.2 connection of the crystal resonator (example) table 7.1 damping resistance frequency [mhz] 248121620 rd [ w ] 1k 500 200 0 0 0 crystal resonator: figure 7.3 shows an equivalent circuit of the crystal resonator. use a crystal resonator with the characteristics listed in table 7.2. c 0 xtal extal c l lrs figure 7.3 crystal resonator equivalent circuit table 7.2 crystal resonator parameters frequency (mhz) parameter 2 4 8 12 16 20 rs max [ w ] 500 120 80 60 50 40 co max [pf] 7 7 7 7 7 7 value to be determined (tbd) 7.2.2 external clock input an external clock signal can be input at the extal pin as shown in figure 7.6. the xtal pin should be left open. the frequency must be equal to the system clock (ck) frequency. the specifications for the waveform of the external clock input are given below. make the external clock frequency the same as the system clock (ck).
hitachi 91 xtal extal open external clock input figure 7.4 external clock input method t exr t exf vil vih 1/2 v cc t exh t exl t cyc figure 7.5 input clock waveform table 7.3 input clock specifications 5 v specifications (fmax = 20 mhz) 3.3 v specifications (fmax = 12.5 mhz) units t exr/f (v il ? ih ) max = 5 max = 10 ns t exh/l (1/2 v cc standard) min = 10 min = 20 ns 7.3 usage notes board design: when designing the board, place the crystal resonator and its load capacitors as close as possible to the xtal and extal pins. route no other signal lines near the xtal and extal pin signal lines to prevent induction from interfering with correct oscillation. see figure 7.6.
92 hitachi xtal extal c l1 c l2 no crossing signal lines figure 7.6 precaution on oscillator circuit board design duty cycle correction circuit: duty cycle corrections are conducted for an input clock over 5 mhz. duty cycles may not be corrected if under 5 mhz, but ac characteristics for the high-level pulse width (t ch ) and low-level pulse width (t cl ) of the clock are satisfied, and the lsi will operate normally. figure 7.7 shows the standard characteristics of a duty cycle correction. this duty cycle correction circuit is not for correcting the input clock's transient fluctuations and jutters. 70 60 50 40 30 125 1020 (mhz) 70 60 50 40 30 input duty input frequency output duty figure 7.7 duty cycle correction circuit standard characteristics
hitachi 93 section 8 bus state controller (bsc) 8.1 overview the bus state controller (bsc) divides address space and outputs control signals for all kinds of memory and peripheral lsis. bsc functions enable the lsi to link directly with dram, sram, rom, and peripheral lsis without the use of external circuits, simplifying system design and allowing high-speed data transfers in a compact system. 8.1.1 features the bsc has the following features. address space is divided into eight areas ? a maximum 4-mbyte of linear address space for each of eight areas, 0e7 (area 1 can be up to 16-mbyte linear space when set for dram) (the space that can actually be used varies with the type of memory connected) ? bus width (8 bits or 16 bits) can be selected by access address ? on-chip rom and ram is accessed in one cycle (32 bits wide) ? wait states can be inserted using the wait pin ? wait state insertion can be controlled through software. register settings can be used to specify the insertion of 1e4 cycles for areas 0, 2, and 6 (long wait function) ? the type of memory connected can be specified for each area. ? outputs control signals for accessing the memory and peripheral lsis connected to the area direct interface to dram ? multiplexes row/column addresses according to dram capacity ? two types of byte access signals (dual-cas system and dual-we system) ? supports burst operation (high-speed page mode) ? supports cas-before-ras refresh and self-refresh access control for all memory and peripheral lsis ? address/data multiplex function parallel execution of external writes and the like with internal access (warp mode) supports parity check and generation for data bus ? odd parity/even parity selectable ? interrupt request generated for parity error (pei interrupt request signal) refresh counter can be used as an 8-bit interval timer ? interrupt request generated at compare match (cmi interrupt request signal) 8.1.2 block diagram figure 8.1 shows the block diagram of the bus state controller.
94 hitachi wcr1 wcr2 wcr3 bcr dcr rcr cash , casl cmi interrupt request dph, dpl pei interrupt request wait rtcsr rtcnt rtcor pcr internal bus interrupt controller bus interface area control unit comparator module bus rd wrh , wrl hbs , lbs ah cs7 to cs0 ras wait control unit dram control unit parity control unit peripheral bus wcr: wait state control register rtcsr: refresh timer control/status register bcr: bus control register rtcnt: refresh timer counter dcr: dram area control register rtcor: refresh time constant register rcr: refresh control register pcr: parity control register figure 8.1 bsc block diagram
hitachi 95 8.1.3 pin configuration table 8.1 shows the bsc pin configuration. table 8.1 pin configuration name abbreviation i/o function chip select 7e0 cs7 e cs0 o chip select signal that indicates the area being accessed read rd o strobe signal that indicates the read cycle high write wrh o strobe signal that indicates write cycle to upper 8 bits low write wrl o strobe signal that indicates write cycle to lower 8 bits write wr * 1 o strobe signal that indicates write cycle high byte strobe hbs * 2 o strobe signal that indicates access to upper 8 bits low byte strobe lbs * 3 o strobe signal that indicates access to lower 8 bits row address strobe ras o dram row address strobe signal high column address strobe cash o column address strobe signal for accessing the upper 8 bits of the dram low column address strobe casl o column address strobe signal for accessing the lower 8 bits of the dram address hold ah o signal for holding the address for address/data multiplexing wait wait i wait state request signal address bus a21ea0 o address output data bus ad15ead0 i/o data i/o. during address/data multiplexing, address output and data input/output. data bus parity high dph i/o parity data i/o for upper byte data bus parity low dpl i/o parity data i/o for lower byte notes: 1. doubles with the wrl pin. (selected by the bas bit of the bcr. see section 8.2.1, bus control register, for details. 2. doubles with the a0 pin. (selected by the bas bit of the bcr. see section 8.2.1, bus control register, for details. 3. doubles with the wrh pin. (selected by the bas bit of the bcr. see section 8.2.1, bus control register, for details. 8.1.4 register configuration the bsc has ten registers (listed in table 8.2) which control space division, wait states, dram interface, and parity check.
96 hitachi table 8.2 register configuration name abbr. r/w initial value address* 1 bus width bus control register bcr r/w h'0000 h'5ffffa0 8,16,32 wait state control register 1 wcr1 r/w h'ffff h'5ffffa2 8,16,32 wait state control register 2 wcr2 r/w h'ffff h'5ffffa4 8,16,32 wait state control register 3 wcr3 r/w h'f800 h'5ffffa6 8,16,32 dram area control register dcr r/w h'0000 h'5ffffa8 8,16,32 parity control register pcr r/w h'0000 h'5ffffaa 8,16,32 refresh control register rcr r/w h'0000 h'5ffffac 8,16,32* 2 refresh timer control/status register rtcsr r/w h'0000 h'5ffffae 8,16,32* 2 refresh timer counter rtcnt r/w h'0000 h'5ffffb0 8,16,32* 2 refresh time constant register rtcor r/w h'00ff h'5ffffb2 8,16,32* 2 notes: 1. only the values of bits a27ea24 and a8ea0 are valid; bits a23ea9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 2. write only with word transfer instructions. see section 8.2.11, register access, for details on writing. 8.1.5 overview of areas the sh microprocessors have 32-bit address spaces on the architecture, but the top 4 bits are ignored. table 8.3 outlines the division of space. as shown, the space is divided into areas 0e7 by the value of the top addresses. each area is allocated a specific type of space. when the area is accessed, a strobe signal that matches the type of area space is generated. this allocates peripheral lsis and memory devices according to the type of the area spaces and allows them to be directly linked to this lsi. some areas are of a fixed type based on their address while others can be selected in registers. area 0 can be used as an on-chip rom space or external memory space. area 1 can be used as dram space or external memory space. dram space enables direct connection to dram and outputs ras , cas and multiplexed addresses. areas 2e4 can only be used as external memory space. area 5 can be used as on-chip peripheral module space or external memory space. area 6 can be used as address/data multiplexed i/o space or external memory space. for address/data multiplexed i/o space, an address and data are multiplexed and input/output from ad15ead0 pins. area 7 can be used as on-chip ram space or external memory space. the bus width of the data bus is basically switched between 8 bit and 16 bit by the value of address bit a27. for the following areas, however, the bus width is determined by conditions other than the a27 bit value.
hitachi 97 on-chip rom space in area 0: always 32 bits external memory space in area 0: 8 bits when md0 pin is 0, 16 bits when the pin is 1 on-chip peripheral module space in area 5: 8 bits when the a8 address bit is 0, 16 bits when it is 1 area 6: if a27 = 0, area 6 is 8 bits when the a14 address bit is 0, 16 bits when a14 is 1 on-chip ram space in area 7: always 32 bits see table 8.6 in section 8.3, address space subdivision, for more information on how the space is divided. 8.2 register descriptions 8.2.1 bus control register (bcr) the bus control register (bcr) is a 16-bit read/write register that selects the functions of areas and status of bus cycles. it is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode. bit: 15 14 13 12 11 10 9 8 bit name: drame ioe warp rddty bas ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit 15 (dram enable bit (drame)): drame selects whether area 1 is used as an external memory space or dram space. 0 sets it for external memory space and 1 sets it for dram space. the setting of the dram area control register is valid only when this bit is set to 1. bit 15: drame description 0 area 1 is external memory space (initial value) 1 area 1 is a dram space bit 14 (multiplexed i/o enable bit (ioe)): ioe selects whether area 6 is used as external memory space or an address/data multiplexed i/o area. 0 sets it for external memory space and 1 sets it for address/data multiplexed i/o space. with address/data multiplexed i/o space, address and data are multiplexed and input/output is from ad15ead0.
98 hitachi bit 14: ioe description 0 area 6 is external memory space (initial value) 1 area 6 is an address/data multiplexed i/o area bit 13 (warp mode bit (warp)): warp selects warp or normal mode. 0 sets it for normal mode and 1 sets it for warp mode. in warp mode, some external accesses are carried out in parallel with internal access. bit 13: warp description 0 normal mode: external and internal accesses are not simultaneously performed (initial value) 1 warp mode: external and internal accesses are simultaneously performed bit 12 (rd duty (rddty)): rddty selects 35% or 50% of the t1 state as the high-level duty cycle ratio of signal rd . 0 sets it for 50%, 1 sets it for 35%. only set to 1 when the operating frequency is a minimum of 10 mhz. bit 12: rddty description 0 rd signal high-level duty cycle is 50% of t1 state (initial value) 1 rd signal high-level duty cycle is 35% of t1 state bit 11 (byte access select (bas)): bas selects whether byte access control signals are wrh , wrl , and a0, or lbs , wr and hbs during word space accesses. when this bit is cleared to 0, wrh , wrl , and a0 signals are valid; when set to 1, lbs , wr , and hbs , signals are valid. bit 11: bas description 0 wrh , wrl , and a0 enabled (initial value) 1 lbs , wr , and hbs enabled bits 10e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.2 wait state control register 1 (wcr1) wait state control register 1 is a 16-bit read/write register that controls the number of states for accessing each area and the whether wait states are used. wcr1 is initialized to h'ffff by a power-on reset. it is not initialized by a manual reset or by the standby mode.
hitachi 99 bit: 15 14 13 12 11 10 9 8 bit name: rw7 rw6 rw5 rw4 rw3 rw2 rw1 rw0 initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: ? ? ? ? ? ? ww1 ? initial value: 1 1 1 1 1 1 1 1 r/w: ? ? ? ? ? ? r/w ? bits 15e8 (wait state control during read (rw7erw0)): rw7erw0 determine the number of states in read cycles for each area and whether or not to sample the signal input from the wait pin. bits rw7erw0 correspond to areas 7e0, respectively. if a bit is cleared to 0, the wait signal is not sampled during the read cycle for the corresponding area. if it is set to 1, sampling takes place. for the external memory spaces of areas 1, 3e5, and 7, read cycles are completed in one state when the corresponding bits are cleared to 0. when they are set to 1, the number of wait states is 2 plus the wait signal value. for the external memory space of areas 0, 2, and 6, read cycles are completed in one state plus the number of long wait states (set in wait state controller 3 (wcr3)) when the corresponding bits are cleared to 0. when they are set to 1, the number of wait states is 1 plus the long wait state; when the wait signal is at low level as well, a wait state is inserted. the dram space (area 1) finishes the column address output cycle in one state (short pitch) when the rw1 bit is 0, and in 2 states plus the wait signal value (long pitch) when rw1 is 1. when rw1 is set to 1, the number of wait states selected in wait state insertion bits 1 and 0 (rlw0 and rlw1) for cas-before-ras (cbr) refresh of the refresh control register (rcr) are inserted during the cbr refresh cycle, regardless of the status of the wait signal. the read cycle of the address/data multiplexed i/o space (area 6) is 4 states plus the wait states from the wait signal, regardless of the setting of the rw6 bit. the read cycle of the on-chip peripheral module space (area 5) finishes in 3 states, regardless of the setting of the rw5 bit, and the wait signal is not sampled. the read cycles of on-chip rom (area 0) and on-chip ram (area 7) finish in 1 state, regardless of the settings of bits rw0 and rw7. the wait signal is not sampled for either. table 8.3 summarizes read cycle state information.
100 hitachi table 8.3 read cycle state description read cycle states external memory space internal space bits 15e8: rw7erw0 wait pin input signal external memory space dram space multi- plexed i/o on-chip peripheral module on-chip rom and ram 0 not sampled during read cycle* 1 areas 1, 3e5,7: 1 state, fixed areas 0, 2, 6: 1 state + long wait state column add- ress cycle: 1 state, fixed (short pitch) 4 states + wait states from wait 3 states, fixed 1 state, fixed 1 sampled during read cycle (initial value) areas 1, 3e5, 7: 2 states + wait states from wait areas 0, 2, 6: 1 state + long wait state + wait state from wait column address cycle: 2 states + wait state from wait (long pitch)* 2 notes: 1. sampled in the address/data multiplexed i/o space 2. during a cbr refresh, the wait signal is ignored and the wait state from the rlw1 and rlw0 bits of rcr is inserted. bits 7e2 (reserved): these bits always read as 1. the write value should always be 1. bit 1 (wait state control during write (ww1)): ww1 determines the number of states in write cycles for the dram space (area 1) and whether or not to sample the wait signal. when the dram enable bit (drame) of the bcr is set to 1 and area 1 is being used as dram space, clearing ww1 to 0 makes the column address output cycle finish in 1 states (short pitch). when ww1 is set to 1, it finishes in 2 states plus the wait states from the wait signal (long pitch). note: write 0 to ww1 only when area 1 is used as dram space (drame bit of bcr is 1). never write 0 to ww1 when area 1 is used as external memory space (drame is 0). bit 1: ww1 dram space (drame = 1) area 1's external memory space (drame = 0) 0 column address cycle: 1 state (short pitch) setting inhibited 1 column address cycle: 2 states + wait state from wait (long pitch) (initial value) 2 states + wait state from wait bit 0 (reserved): this bit always reads 1. the write value should always be 1.
hitachi 101 8.2.3 wait state control register 2 (wcr2) wait state control register 2 is a 16-bit read/write register that controls the number of states for accessing each area with a dma single address mode transfer and whether wait states are used. wcr2 is initialized to h'ffff by a power-on reset. it is not initialized by a manual reset or by the standby mode. bit: 15 14 13 12 11 10 9 8 bit name: drw7 drw6 drw5 drw4 drw3 drw2 drw1 drw0 initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: dww7 dww6 dww5 dww4 dww3 dww2 dww1 dww0 initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 15e8 (wait state control during single-mode dma transfer (drw7edrw0)): drw7e drw0 determine the number of states in single-mode dma memory read cycles for each area and whether or not to sample the wait signal. bits drw7edrw0 correspond to areas 7e0, respectively. if a bit is cleared to 0, the wait signal is not sampled during the single-mode dma memory read cycle for the corresponding area. if it is set to 1, sampling takes place. for the external memory spaces of areas 1, 3e5, and 7, single-mode dma memory read cycles are completed in one state when the corresponding bits are cleared to 0. when they are set to 1, the number of wait states is 2 plus the wait states from the wait signal. for the external memory space of areas 0, 2, and 6, single-mode dma memory read cycles are completed in one state plus the long wait state number (set in wait state controller 3 (wcr3)) when the corresponding bits are cleared to 0. when they are set to 1, the number of wait states is 1 plus the long wait state; when the wait signal is at low level as well, a wait state is inserted. the dram space (area 1) finishes the column address output cycle in one state (short pitch) when the drw1 bit is 0, and in 2 states plus the wait states from the wait signal (long pitch) when drw1 is 1. the single-mode dma memory read cycle of the address/data multiplexed i/o space (area 6) is 4 states plus the wait states from the wait signal, regardless of the setting of the drw6 bit. table 8.4 summarizes single-mode dma memory read cycle state information.
102 hitachi table 8.4 single-mode dma memory read cycle states (external memory space) description single-mode dma memory read cycle states (external memory space) bits 15e8: drw7edrw0 wait pin input signal external memory space dram space multiplexed i/o 0 not sampled during single-mode dma memory read cycle* areas 1, 3e5,7: 1 state, fixed areas 0, 2, 6: 1 state + long wait state column address cycle: 1 state, fixed (short pitch) 4 states + wait states from wait 1 sampled during single-mode dma memory read cycle (initial value) areas 1, 3e5, 7: 2 states + wait states from wait areas 0, 2, 6: 1 state + long wait state + wait state from wait column address cycle: 2 states + wait state from wait (long pitch) note: sampled in the address/data multiplexed i/o space. bits 7e0 (single-mode dma memory write wait state control (dww7edww0)): dww7e dww0 determine the number of states in single-mode dma memory write cycles for each area and whether or not to sample the wait signal. bits dww7edww0 correspond to areas 7e0, respectively. if a bit is cleared to 0, the wait signal is not sampled during the single- mode dma memory write cycle for the corresponding area. if it is set to 1, sampling takes place. the number of states for areas accesses based on bit settings are the same as indicated for single-mode dma memory read cycles. see bits 15e8, wait state control during single-mode dma memory transfer (drw7edrw0), for details. table 8.5 summarizes single-mode dma memory write cycle state information.
hitachi 103 table 8.5 single-mode dma memory write cycle states (external memory space) description single-mode dma memory write cycle states (external memory space) bits 15e8: dww7edww0 wait pin input signal external memory space dram space multiplexed i/o 0 not sampled during single-mode dma memory write cycle* areas 1, 3e5,7: 1 state, fixed areas 0, 2, 6: 1 state + long wait state column address cycle: 1 state, fixed (short pitch) 4 states + wait state from wait 1 sampled during single-mode dma memory write cycle (initial value) areas 1, 3e5, 7: 2 states +wait state from wait areas 0, 2, 6: 1 state + long wait state + wait statefrom wait column address cycle: 2 states + wait state from wait (long pitch) note: sampled in the address/data multiplexed i/o space. 8.2.4 wait state control register 3 (wcr3) wait state control register 3 is a 16-bit read/write register that controls wait pin pull-up and the insertion of long wait states. wcr3 is initialized to h'f800 by a power-on reset. it is not initialized by a manual reset or by the standby mode. bit: 15 14 13 12 11 10 9 8 bit name: wpu a02lw1 a02lw0 a6lw1 a6lw0 ? ? ? initial value: 1 1 1 1 1 0 0 0 r/w: r/w r/w r/w r/w r/w ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit 15 (wait pin pull-up control (wpu)): wpu controls whether the wait pin is pulled up or not. when cleared to 0, the pin is not pulled up; when set to 1, it is pulled up.
104 hitachi bit 15: wpu description 0 wait pin is not pulled up 1 wait pin is pulled up (initial value) bits 14 and 13 (long wait insertion in areas 0 and 2, bits 1, 0 (a02lw1 and a02lw0)): a02lw1 and a02lw0 select the long wait states to be inserted (1e4 states) when accessing external memory space of areas 0 and 2. bit 14: a02lw1 bit 13: a02lw0 description 0 0 inserts 1 state 1 inserts 2 states 1 0 inserts 3 states 1 inserts 4 states (initial value) bits 12 and 11 (long wait insertion in area 6, bits 1, 0 (a6lw1 and a6lw0)): a6lw1 and a6lw0 select the long wait states to be inserted (1e4 states) when accessing external memory space of area 6. bit 12: a6lw1 bit 11: a6lw0 description 0 0 inserts 1 state 1 inserts 2 states 1 0 inserts 3 states 1 inserts 4 states (initial value) bits 10e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.5 dram area control register (dcr) the dram area control register (dcr) is a 16-bit read/write register that selects the type of dram control signal, the number of precharge cycles, the burst operation mode and the use of address multiplexing. dcr settings are valid only when the drame bit of bcr is set to 1. it is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode.
hitachi 105 bit: 15 14 13 12 11 10 9 8 bit name: cw2 rasd tpc be cdty mxe mxc1 mxc0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit 15 (dual-cas or dual-we select bit (cw2)): when accessing a 16-bit bus width space, cw2 selects the dual-cas or the dual-we method. when cleared to 0, the cash , casl , and wrl signals are valid ; when set to 1, the casl , wrh , and wrl signals are valid. when accessing an 8-bit space, only casl and wrl signals are valid, regardless of cw2 settings. bit 15l: cw2 description 0 dual-cas: cash , casl , and wrl signals are valid (initial value) 1 dual-we: casl , wrh , and wrl signals are valid bit 14 (ras down (rasd)): when dram access pauses, rasd determines whether to keep ras low while waiting for the next dram access (ras down mode) or return it to high (ras up mode). when cleared to 0, the ras signal returns to high; when set to 1, it stays at low. bit 14: rasd description 0 ras up mode: return ras signal to high and wait for the next dram access (initial value) 1 ras down mode: keep ras signal low and wait for the next dram access bit 13 (ras precharge cycle count (tpc)): tpc selects whether the ras signal precharge cycle (t p ) will be 1 state or 2. when tpc is cleared to 0, a 1-state precharge cycle is inserted; when 1 is set, a 2-state precharge cycle is inserted. bit 13: tpc description 0 inserts 1-state precharge cycle (initial value) 1 inserts 2-state precharge cycle
106 hitachi bit 12 (burst operation enable (be)): be selects whether or not to perform burst operation, a high speed page mode. when burst operation is not selected (0), the row address is not compared but instead is transferred to the dram every time and full access is performed. when burst operation is selected (1), row addresses are compared and burst operation with the same row address as the previous is performed (in this access, no row address is output and the column address and cas signal alone are output). bit 12: be description 0 normal mode: full access (initial value) 1 burst operation: high-speed page mode bit 11 (cas duty (cdty)): cdty selects 35% or 50% of the t c state as the high-level duty ratio of the signal cas in the short-pitch access. when cleared to 0, the cas signal high level duty is 50%; when set to 1, it is 35%. only set to 1 when the operating frequency is a minimum of 10 mhz. bit 11: cdty description 0 cas signal high level duty cycle is 50% of the t c state (initial value) 1 cas signal high level duty cycle is 35% of the t c state bit 10 (multiplex enable bit (mxe)): mxe determines whether or not dram row and column addresses are multiplexed. when cleared to 0, addresses are not multiplexed; when set to 1, they are multiplexed. bit 10: mxe description 0 multiplex of row and column addresses disabled (initial value) 1 multiplex of row and column addresses enabled bits 9 and 8 (multiplex shift count 1 and 0 (mxc1 and mxc0)): shift row addresses downward by a certain number of bits (8e10) when row and column addresses are multiplexed (mxe = 1). regardless of the mxe bit setting, these bits also select the range of row addresses compared in burst operation.
hitachi 107 bit 9: mxc1 bit 8: mxc0 row address shift (mxe = 1) row address bits compared (in burst operation) (mxe = 0 or 1) 0 0 8 bits (initial value) a8ea27 (initial value) 1 9 bits a9ea27 1 0 10 bits a10ea27 1 reserved reserved bits 7e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.6 refresh control register (rcr) the refresh control register (rcr) is a 16-bit read/write register that controls the start of refreshing and selects the refresh mode and the number of wait states during refresh. it is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode. to prevent rcr from being written incorrectly, it must be written by a different method from most other registers. a word transfer operation is used, h'5a is written in the top byte, and the actual data is written in the lower byte. for details, see section 8.2.11, notes on register access. bit: 15 14 13 12 11 10 9 8 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: rfshe rmode rlw1 rlw0 ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w ? ? ? ? bit 15e8 (reserved): these bits always read as 0. bit 7 (refresh control (rfshe)): rfshe determines whether or not to perform dram refresh operations. when this bit is cleared to 0, no dram refresh control is performed and the refresh timer counter (rtcnt) can be used as an 8-bit interval timer. when set to 1, dram refresh control is performed.
108 hitachi bit 7: rfshe description 0 refresh control disabled. rtcnt can be used as an 8-bit interval timer. (initial value) 1 refresh control enabled bit 6 (refresh mode (rmode)): when dram refresh control is selected (rfshe = 1), rmode selects whether to perform cas-before-ras (cbr) refresh or self-refresh. when this bit is cleared to 0, a cbr refresh is performed at the cycle set in the refresh timer control/status register (rtcsr) and refresh time constant register (rtcor). when set to 1, it the dram does a self-refresh. when refresh control is not selected (rfshe = 0), the rmode bit setting is not valid. when canceling self-refresh, set rmode to 0 with rfshe set to 1. bit 6: rmode description 0 cas-before-ras refresh (initial value) 1 self-refresh bits 5 and 4?insert wait states during cbr refresh bits 1 and 0 (rlw1, rlw0): these bits select the number of wait states to be inserted (1e4) during cas-before-ras refresh. when cbr refresh is performed and the rw1 bit of wcr1 is set to 1, the number of wait states selected in the rlw1 and rlw0 is inserted regardless of the wait signal. when the rw1 bit is cleared to 0, the rlw1 and rlw0 bit settings are ignored and no wait states are inserted. bit 5: rlw1 bit 4: rlw0 description 0 0 inserts 1 state (initial value) 1 inserts 2 states 1 0 inserts 3 states 1 inserts 4 states bits 3e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.7 refresh timer control/status register (rtcsr) the refresh timer control/status register (rtcsr) is a 16-bit read/write register that selects the clock input to refresh timer counter (rtcnt) and controls compare match interrupts (cmi). it is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode. to prevent rtcsr from being written incorrectly, it must be written by a different method from most other registers. a word transfer operation is used, h'a5 is written in the top byte and the actual data is written in the lower byte. for details, see section 8.2.11, notes on register access.
hitachi 109 bit: 15 14 13 12 11 10 9 8 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: cmf cmie cks2 cks1 cks0 ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w ? ? ? bits 15e8 (reserved): these bits always read as 0. bit 7 (compare match flag (cmf)): cmf is a flag that indicates whether the values of rtcnt and the refresh time constant register (rtcor) match. when 0, the value of rtcnt and rtcor do not match; when 1, the value of rtcnt and rtcor match. bit 7: cmf description 0 rtcnt does not equal the value of rtcor (initial value) to clear cmf, the cpu must read cmf after it has been set to 1, then write a 0 in this bit 1 value rtcnt is equal to the value of rtcor bit 6 (compare match interrupt enable (cmie)): cmie enables or disables the compare match interrupt (cmi) generated when cmf is set to 1 in rtcsr (rtcnt value = rtcor value). when cleared to 0, cmi interrupt is disabled; when set to 1, it is enabled. bit 6: cmie description 0 compare match interrupt request (cmi) is disabled (initial value) 1 compare match interrupt request (cmi) is enabled bits 5e3 (clock select bits 2e0 (cks2ecks0)): cks2ecks0 select the clock input to rtcnt from among the seven types of clocks created by dividing the system clock ( f ). when the input clock is selected with the cks2ecks0 bits, rtcnt starts to increment.
110 hitachi bit 5: cks2 bit 4: cks1 bit 3: cks0 description 0 0 0 clock input disabled (initial value) 1 f /2 10 f /8 1 f /32 100 f /128 1 f /512 10 f /2048 1 f /4096 bits 2e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.8 refresh timer counter (rtcnt) the refresh timer counter (rtcnt) is a 16-bit read/write register that is used as an 8-bit upcounter that generates the refresh or interrupt request. when the input clock is selected by clock select bits 2e0 (cks2ecks0) in rtcsr, that clock makes the rtcnt start incrementing. when the values of rtcnt and the refresh time constant register (rtcor) match, rtcnt is cleared to h'0000 and the cmf flag of the rtcsr is set to 1. when the rfshe bit of the rcr is also set to 1, a cas-before-ras refresh is performed. when the cmie bit of the rtcsr is also set to 1, a compare match interrupt (cmi) is generated. bits 15e8 are reserved bits and do not count. these bits always read as 0. rtcnt is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode. to prevent rtcsr from being written incorrectly, it must be written by a different method from most other registers. a word transfer operation is used, h'69 is written in the top byte and the actual data is written in the lower byte. for details, see section 8.2.11, register access.
hitachi 111 bit: 15 14 13 12 11 10 9 8 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w
112 hitachi 8.2.9 refresh time constant register (rtcor) the refresh time constant register (rtcor) is a 16-bit read/write register that sets the compare match cycle used with rtcnt. the values in rtcor and rtcnt are constantly compared. when they match, the compare-match flag (cmf) is set in rtcnt and rtcsr is cleared to h'0000. if the bit rfshe in rcr is set to 1 when this happens, a cas before ras (cbr) refresh is performed. when the cmie bit of the rtcsr is also set to 1, a compare match interrupt (cmi) is generated. bits 15e8 are reserved bits and cannot be used to set the cycle. these bits always read as 0. rtcor is initialized to h'00ff by a power-on reset, but is not initialized by a manual reset or by the standby mode. to prevent rtcor from being written incorrectly, it must be written by a different method from most other registers. a word transfer operation is used, h'96 is written in the top byte and the actual data is written in the lower byte. for details, see section 8.2.11, note on register access. bit: 15 14 13 12 11 10 9 8 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 8.2.10 parity control register (pcr) the parity control register (pcr) is a 16-bit read/write register that selects the parity polarity and space to be parity checked. pcr is initialized to h'0000 by a power-on reset, but is not initialized by a manual reset or by the standby mode.
hitachi 113 bit: 15 14 13 12 11 10 9 8 bit name: pef pfrc peo pchk1 pchk0 ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w ? ? ? bit: 7 6 5 4 3 2 1 0 bit name: ? ? ? ? ? ? ? ? initial value: 0 0 0 0 0 0 0 0 r/w: ? ? ? ? ? ? ? ? bit 15 (parity error flag (pef)): when a parity check is done, pef indicates whether a parity error has occurred. 0 indicates that no parity error has occurred; 1 indicates that a parity error has occurred. bit 15: pef description 0 no parity error (initial value). cleared by reading pef after it has been set to 1, then writing 0 in pef. 1 parity error has occurred. bit 14 (parity output force (pfrc)): pfrc selects whether to produce a forced parity output for testing the parity error check function. when cleared to 0, there is no forced output; when set to 1, it produces a forced output of high level from the dph and dpl pins when data is output, regardless of the parity. bit 14: pfrc description 0 parity output not forced (initial value) 1 high output forced bit 13 (parity polarity (peo)): peo selects even or odd parity. when cleared to 0, parity is even; when set to 1, parity is odd. bit 13: peo description 0 even parity (initial value) 1 odd parity bits 12 and 11 (parity check enable bits 1, 0 (pchk1 and pchk0)): these bits determine whether or not a parity is checked and generated, and select the check and generation spaces.
114 hitachi bit 12: pchk1 bit 11: pchk0 description 0 0 parity not checked and not generated (initial value) 1 parity checked and generated only in dram area 1 0 parity checked and generated in dram area and area 2 1 reserved bits 10e0 (reserved): these bits always read as 0. the write value should always be 0. 8.2.11 notes on register access rcr, rtcsr, rtcnt, and rtcor differ from other registers in being more difficult to write. data requires a password when it is written. this prevents data from being mistakenly overwritten by program overruns and the like. writing to rcr, rtcsr, rtcnt, and rtcor: use only word transfer instructions. you cannot write with byte transfer instructions. as figure 8.2 shows, when writing to rcr, place h'5a in the upper byte and the write data in the lower byte. when writing to rtcsr, place h'a5 in the upper byte and the write data in the lower byte. when writing to rtcnt, place h'69 in the upper byte and the write data in the lower byte. when writing to rtcor, place h'96 in the upper byte and the write data in the lower byte. these transfers write data in the lower byte to the respective registers. if the upper byte differs from the above passwords, no writing occurs. h'5a write data rcr 15 0 87 h'a5 write data rtcsr 15 0 87 h'69 write data rtcnt 15 0 87 h'96 write data rtcor 15 0 87 figure 8.2 writing to rcr, rtcsr, rtcnt, and rtcor reading from rcr, rtcsr, rtcnt, and rtcorp: these registers are read like other registers. they can be read by byte and word transfer instructions. if read by word transfer, the value of the upper eight bits is h'00.
hitachi 115 8.3 address space subdivision 8.3.1 address spaces and areas figure 8.3 shows the address format used in this lsi. a0 a21 a23,a22 a26ea24 a31ea28 a27 output address: output from address pins a21ea0 ignore: only valid when the address multiplex function is being used in the dram space (area 1); not output in other cases. when not output, becomes shadow. area selection: decoded to become chip select signals cs0 e cs7 for areas 0e7 basic bus width selection: not output externally, but used for basic bus width selection when 0, (h'0000000eh'7ffffff), the basic bus width is 8 bits. when 1, (h'8000000eh'fffffff) the basic bus width is 16 bits. ignore: always ignore, not output externally 4 gbyte space 16 mbyte space 4 mbyte space 128 mbyte space figure 8.3 address format since this lsi uses a 32-bit address, 4 gbytes of space can be accessed on the architecture; however, the upper 4 bits (a31ea28) are always ignored and not output. bit a27 is basically only used for switching the bus width. when the a27 bit is 0 (h'0000000eh'7ffffff), the bus width is 8 bits; when the a27 bit is 1 (h'8000000eh'fffffff), the bus width is 16 bits. of the remaining 27 bits (a26ea0), a total 128 mbyte can thus be accessed. the 128 mbyte space is subdivided into 8 areas (areas 0e7) of 16 mbytes each according to the values of bits a26ea24. the space with bits a26ea24 as 000 is area 0 and the space 111 is area 7. the a26ea24 bits are decoded and become the chip select signals ( cs0 e cs7 ) of the corresponding areas 0e7 and output. table 8.6 shows how the space is divided.
116 hitachi table 8.6 how space is divided area address assign-able memory capacity (linear space) bus width cs output 0 h'0000000 e h'0ffffff on-chip rom* 1 16 kb* 3 32 kb* 4 32 ? external memory* 2 4 mb 8/16* 5 cs0 1 h'1000000 e h'1ffffff external memory 4 mb 8 cs1 dram* 6 16 mb 8 ras cas 2 h'2000000 e h'2ffffff external memory 4 mb 8 cs2 3 h'3000000 e h'3ffffff external memory 4 mb 8 cs3 4 h'4000000 e h'4ffffff external memory 4 mb 8 cs4 5 h'5000000 e h'5ffffff on-chip peripheral module 512 b 8/16* 7 ? 6 h'6000000 e h'6ffffff external memory* 9 4 mb 8/16* 8 cs6 multiplexed i/o 4 mb 7 h'7000000 e h'7ffffff external memory 4 mb 8 cs7 0 h'8000000 e h'8ffffff on-chip rom* 1 16 kb* 3 32 kb* 4 32 ? external memory* 2 4 mb 8/16* 5 cs0 1 h'9000000 e h'9ffffff external memory 4 mb 16 cs1 dram* 6 16 mb 16 ras cas 2 h'a000000 e h'affffff external memory 4 mb 16 cs2 3 h'b000000 e h'bffffff external memory 4 mb 16 cs3 4 h'c000000 e h'cffffff external memory 4 mb 16 cs4 5 h'd000000 e h'dffffff external memory 4 mb 16 cs5 6 h'e000000 e h'effffff external memory 4 mb 16 cs6 7 h'f000000 e h'fffffff on-chip ram 1 kb 32 ? notes: 1. when md2emd0 pins are 010 2. when md2emd0 pins are 000 or 001 3. for sh7020 4. for sh7021 5. select with md0 pin 6. select with drame bit in bcr 7. divided into 8-bit and 16-bit space according to value of address bit a8 (long word accesses are inhibited, however, in on-chip peripheral modules with bus widths of 8 bits. some on-chip peripheral modules with bus widths of 16 bits also have registers that are only byte-accessible and registers for which byte access is inhibited. for details, see the sections on the individual modules.) 8. divided into 8-bit space and 16-bit space by value of address bit a14 9. select with ioe bit of bcr
hitachi 117 as figure 8.4 shows, specific spaces such as dram space and address/data multiplexed i/o space are allocated to the 8 areas. each of the spaces is equipped with the necessary interfaces. the control signals needed by dram and peripheral lsis will be output by the chip to devices connected to an area allocated to the appropriate type of space. 8.3.2 bus width the primary bus width selection on for this chip is made by switching between 8-bit and 16 bit using the a27 bit. when a27 is 0, the bus width is 8 bits and data is input/output through the ad7ead0 pins; when a27 is 1, the size is 16 bits and data is input/output through the ad15e ad0 pins for word accesses. for byte access, the top byte is input/output through ad15ead8 and the lower byte through ad7ead0. when the bus width is 8 bits or byte access is being performed with a 16-bit bus width, the status of the eight ad pins that are not inputting/outputting data is as shown in appendix b, pin states. bus widths are also determined by conditions other than the a27 bit for specific areas: area 0 is an 8-bit external memory space when the md2emd0 pins are 000, a 16-bit external memory space when the same bits are 001, and a 32-bit on-chip rom space when they are 010. area 5 is an 8-bit on-chip peripheral module space when the a27 bit and a8 bit are both 0 and a 16-bit on-chip peripheral module space when the a27 bit is 0 and the a8 bit is 1. when the a27 bit is 1, it is a 16-bit external memory space. area 6 is an 8-bit bus width when the a27 bit and a14 bit are both 0 and a 16-bit bus width when the a27 bit is 0 and the a14 bit is 1. when the a27 bit is 1, it is a 16-bit space. area 7 is a 32-bit on-chip ram space when the a27 bit is 1 and an 8-bit external memory space when the a27 bit is 0. word (16-bit) data accessed from 8-bit bus areas and longword (32-bit) data accessed from 16-bit bus areas require two consecutive accesses. longword (32-bit) data accessed from 8-bit bus areas requires four consecutive accesses. 8.3.3 chip select signals ( cs0 e cs7 ) when the a26ea24 bits of the address are decoded, they become chip select signals ( cs0 e cs7 ) for areas 0e7. when an area is accessed, the corresponding chip select pins are driven low. table 8.7 shows the relationship between the a26ea24 bits and the chip select signals.
118 hitachi table 8.7 a26ea24 bits and chip select signals address a26 a25 a24 area selected chip select pin driven low 0 0 0 area 0 cs0 1 area 1 cs1 1 0 area 2 cs2 1 area 3 cs3 1 0 0 area 4 cs4 1 area 5 cs5 1 0 area 6 cs6 1 area 7 cs7 the chip select signal is output only for external accesses. when accessing the on-chip rom (area 0), on-chip peripheral modules (area 5) and on-chip ram (area 7), the cs0 , cs5 , and cs7 pins are not driven low. when accessing dram space (area 1), select the ras and cas signals with the pin function controller. 8.3.4 shadows the size of each area is 16 mbytes, which can be specified with 24 address bits a23ea0 for 8-bit spaces and 16-bit spaces alike. bits a23 and a22, however, output externally only when the address multiplex function is used in dram space (area 1); in all other cases, there is no output, so the actually accessible area for all areas is the 4 mbyte that can be specified with 22 bits a21e a0. no matter what the values of a23 and a22, the same 4 mbytes of actual space is accessed. as illustrated in figure 8.4 (a), the a23 and a22 bit regions 00, 01, 10 and 11 are called shadows of actual areas. shadows are allocated in 4-mbyte units for both 8-bit and 16-bit bus widths. when the same addresses h'3200000, h'3600000, h'3a00000 and h'3e00000 are specified for values a21ea0, as shown in figure 8.4 (b), the same actual space is accessed regardless of the a23 and a22 bits. in areas whose bus widths are switchable using the a27 address bit, the shadow of the same actual space is allocated to both a27 = 0 spaces and a27 = 1 spaces (figure 8.4(a)). when the value of a27 is changed, the valid ad pins switch from ad15ead0 to ad7ead0, but the actual space accessed remains the same. the spaces of on-chip rom (area 0), dram (area 1), on-chip peripheral modules (area 5) and on- chip ram (area 7) have shadows of different sizes from those discussed above. see section 8.3.5, description of areas, for details.
hitachi 119 logical address space h'b000000 h'3000000 actual space area accessible with a21ea0 4 mbytes shadow (a23, a22 = 00) shadow (a23, a22 = 01) shadow (a23, a22 = 10) shadow (a23, a22 = 11) h'b3fffff h'b400000 h'3400000 h'b7fffff h'b800000 h'bbfffff h'bc00000 h'bffffff h'3800000 h'3c00000 16-bit space 8-bit space h'33fffff h'37fffff h'3bfffff actual space location actually accessed logical address space location indicated by address location indicated by address location indicated by address location indicated by address 8-bit space h'3000000 h'3200000 h'33fffff h'3400000 h'3600000 h'3a00000 h'3e00000 h'37fffff h'3800000 h'3bfffff h'3c00000 h'3ffffff a. shadow allocation b. actual space accessed when addresses are specified h'3ffffff figure 8.4 shadows
120 hitachi 8.3.5 area description area 0: area 0 is the area where addresses a26ea24 are 000 and its address range is h'0000000e h'0ffffff and h'8000000eh'8ffffff. figure 8.5 is a memory map of area 0. area 0 can be set for use as on-chip rom space or external memory space with the mode pins (md2emd0). the md2emd0 pins also determine the bus width, regardless of the a27 address bit. when md2emd0 are 000, area 0 is an 8-bit external memory space; when they are 001, area 0 is a 16-bit external memory space; and when they are 010, it is a 32-bit on-chip rom space. in the sh7020, the capacity of the on-chip rom is 16 kbyte, so bits a23ea14 are ignored in on- chip rom space and the shadow is in 16 kbyte units. in the sh7021, the capacity of the on-chip rom is 32 kbyte, so bits a23ea15 are ignored in on-chip rom space and the shadow is in 32 kbyte units. the cso signal is disabled in on-chip rom space. in external memory space, the a23 and a22 bits are not output and the shadow is in 4-mbyte units. when external memory space is accessed, the cs0 signal is valid. the external memory space has a long wait function, so between 1 and 4 states can be selected for the number of long waits inserted into the bus cycle using the areas 0 and 2 long wait insertion bits (a02lw1, a02lw0) of wait state controller 3 (wcr3).
hitachi 121 h'8000000 h'83fffff h'8400000 h'87fffff h'8800000 h'8bfffff h'8c00000 h'8ffffff h'0000000 h'0400000 h'0800000 h'0c00000 h'03fffff h'07fffff h'0bfffff shadow shadow shadow shadow 8 or 16 bit space md2emd0 = 000 or 001 md2emd0 = 010 h'8000000 h'8003fff(sh7020) h'8ffc000 (sh7020) h'8ff8000 (sh7021) on-chip rom sh7020: 16 kbyte sh7021: 32 kbyte valid addresses a15ea0 (a23ea16 ignored) cs0 not valid shadow shadow h'8007fff(sh7021) shadow shadow shadow shadow actual space logical address space logical address space h'0ffffff h'0ffffff 32-bit space h'0ffc000 (sh7020) 32-bit space actual space md2emd0 = 000: 8-bit access, 001: 16-bit access valid addresses a21ea0 (a23 and a22 not output) cs0 valid long wait function h'0000000 h'0003fff (sh7020) h'0007fff (sh7021) h'004000 (sh7020) h'0008000 (sh7021) 8 or 16 bit space external memory space (4 mbytes) h'8004000(sh7020) h'8008000(sh7021) h'0ff8000 (sh7021) note: the bus width of area 0 is determined by the md2emd0 pins regardless of the a27 bit setting. figure 85 memory map of area 0 area 1: area 1 is the area where addresses a26ea24 are 001 and its address range is h'1000000e h'1ffffff and h'9000000eh'9ffffff. figure 8.6 is a memory map of area 1. area 1 can be set for use as dram space or external memory space with the dram enable bit (drame) of the bus control register (bcr). when the drame bit is 0, it is external memory space; when drame is 1, it is dram space. in external memory space, the bus width is 8 bits when the a27 bit is 0 and 16 bits when it is 1. bits a23 and a22 are not output and the shadow is in 4-mbyte units. when external memory is accessed, the cs1 signal is valid. dram space is a type of external memory space, but it is configured especially to be connected to dram so it outputs strobe signals required for this purpose. its bus width is 8 bits when it is 0 and 16 bits when it is 1. when the multiplex enable bit (mxe) of the dram control register (dcr) is
122 hitachi set to 1 to use the address multiplex function, bits a23ea0 are multiplexed and output from pins a15ea0, so a maximum 16-mbyte space can be used. when dram space is accessed, the cs1 signal is not valid and the pin function controller should be set for access with cas ( cash and casl ) and ras signals. h'9000000 h'93fffff h'9400000 h'97fffff h'9800000 h'9bfffff h'9c00000 h'9ffffff h'1000000 h'1400000 h'1800000 h'1c00000 h'13fffff h'17fffff h'1bfffff h'1ffffff shadow shadow shadow external memory space (4 mbytes) a27 = 0: 8-bit space valid address a21ea0 (a23 and a22 not output) cs1 valid drame = 0 or drame = 1, mxe = 0 logical address space h'9000000 h'9ffffff h'1000000 h'1ffffff dram space (maximum 16 mbytes) drame = 1 logical address space actual space a27 = 1: 16-bit space a27 = 0: 8-bit space a27 = 1: 16-bit space multiplexed (mxe = 1): 16-bit space not multi- plexed (mxe = 0): 4 mbyte space cs1 not valid ( cas , ras output) actual space shadow shadow figure 8.6 memory map of area 1 areas 2e4: areas 2e4 are the areas where addresses a26ea24 are 010, 011 and 100, respectively, and their address ranges are h'2000000eh'2ffffff and h'a000000eh'affffff (area 2), h'3000000eh'3ffffff and h'b000000eh'bffffff (area 3), and h'4000000eh'4ffffff and h'c000000eh'cffffff (area 4). figure 8.7 is a memory map of area 2, which is representative of areas 2e4.
hitachi 123 areas 2e4 are always used as external memory space. the bus width is 8 bits when the a27 bit is 0 and 16 bits when it is 1. a23 and a22 bits are not output and the shadow is in 4-mbyte units. when areas 2e4 are accessed, the cs2 , cs3 , and cs4 signals are valid. area 2 has a long wait function, so between 1 and 4 states can be selected for the number of long waits inserted into the bus cycle using the bits a02lw1 and a02lw0 of wcr3. h'a000000 h'a3fffff h'a400000 h'a7fffff h'a800000 h'abfffff h'ac00000 h'affffff h'2000000 h'2400000 h'2800000 h'2c00000 h'23fffff h'27fffff h'2bfffff h'2ffffff shadow shadow shadow shadow external memory space (4 mbytes) logical address space 16-bit space 8-bit space actual space valid addresses a21ea0 (a23 and a22 not output) cs2 valid long wait function figure 8.7 memory map of area 2
124 hitachi area 5: area 5 is the area where addresses a26ea24 are 101 and its address range is h'5000000e h'5ffffff and h'd000000eh'dffffff. figure 8.8 is a memory map of area 5. area 5 is allocated to on-chip peripheral module space when the a27 address bit is 0 and external memory space when a27 is 1. in on-chip peripheral module space, bits a23ea9 are ignored and the shadows are in 512-byte units. the bus width is 8 bits when the a8 bit is 0 and 16 bits when a8 is 1. when on-chip peripheral module space is accessed, the cs5 signal is not valid. in external memory space, the a23 and a22 bits are not output and the shadow is in 4-mbyte units. the bus width is always 16 bits. when external memory space is accessed, the cs5 signal is valid. h'd000000 h'd400000 h'd800000 h'dc00000 h'd3fffff h'd7fffff h'dbfffff h'dffffff shadow shadow shadow shadow external memory space (4 mbytes) h'5000000 h'5ffffff shadow shadow actual space shadow shadow shadow shadow h'5fffe00 h'50001ff logical address space 8 or 16-bit space on chip peripheral module space (512 bytes) a8 = 0: 8-bit space a8 = 1: 16-bit space* ignored addresses: a23ea9 (valid addresses a8ea0) cs5 not valid logical address space 16-bit space actual space valid addresses a21ea0 a23 and a22 not output) cs5 valid note: some registers in onchip peripheral modules can only be accessed as 8-bit registers even though they occupy 16 bits (see appendix a). figure 8.8 memory map of area 5 area 6: area 6 is the area where addresses a26ea24 are 110 and its address range is h'6000000e h'6ffffff and h'e000000eh'effffff. figure 8.9 is a memory map of area 6.
hitachi 125 in area 6, the space when a27 is 0 is allocated to address/data multiplexed i/o space when the multiplexed i/o enable bit (ioe) of the bus control register (bcr) is 1 and external memory space when the ioe bit is 0. when a27 is 1, it is always external memory space. the multiplexed i/o space is a type of external memory space but the address and data are multiplexed and output from ad15ead0 or ad7ead0. the bus width is 8 bits when the a14 bit is 0 and 16 bits when the a14 bit is 1. the a23 and a22 bits are not output and the shadow is in 4- mbyte units. when multiplexed i/o space is accessed, the cs6 signal is valid. in external memory space, the bus width is 8 bits when both the a27 and a14 bits are 0 and 16 bits when the a27 bit is 0 and the a14 bit is 1. when the a27 bit is 1, it is always a 16-bit space. the a23 and a22 bits are not output and the shadow is in 4-mbyte units. when external memory is accessed, the cs6 signal is valid. the external memory space has a long wait function so between 1 and 4 states can be selected for the number of long waits inserted into the bus cycle using the area 6 long wait insertion bits (a6lw1 and a6lw0) of wcr3.
126 hitachi h'e000000 h'e400000 h'e800000 h'ec00000 h'e3fffff h'e7fffff h'ebfffff h'effffff shadow shadow shadow shadow external memory space (4 mbytes) h'6000000 h'6400000 h'6800000 h'6c00000 h'63fffff h'67fffff h'6bfffff h'6ffffff shadow shadow shadow shadow multiplexed i/o space or external memory space (4 mbytes) logical address space logical address space 8 or 16-bit space 16-bit space actual space actual space ioe = 1: address/data multiplexed i/o space; ioe = 0: external memory space a14 = 0: 8-bit space a14 = 1: 16-bit space valid addresses a21ea0 (a23 and a22 not output) cs6 valid long wait function valid addresses a21ea0 (a23 and a22 not output) cs6 valid long wait function figure 8.9 memory map of area 6 area 7: area 7 is the area where addresses a26ea24 are 111 and its address range is h'7000000e h'7ffffff and h'f000000eh'fffffff. figure 8.10 is a memory map of area 7. area 7 is allocated to external memory space when a27 is 0 and on-chip ram space when a27 is 1. in external memory space, the bus width is 8 bits. the a23 and a22 bits are not output and the shadow is in 4-mbyte units. when external memory is accessed, the cs7 signal is valid. the on-chip ram space has an bus width of 32 bits. the on-chip ram capacity is 1 kbytes, so a23ea10 are ignored and the shadows are in 8-kbyte units. during on-chip ram access, the cs7 signal is not valid.
hitachi 127 h'7000000 h'7400000 h'7800000 h'7c00000 h'73fffff h'77fffff h'7bfffff h'7ffffff shadow shadow shadow shadow external memory space (4 mbytes) h'f000000 h'fffffff shadow shadow shadow shadow shadow shadow h'ffffc00 h'f0003ff logical address space logical address space actual space actual space 8-bit space 32-bit space on-chip ram space 1 kbytes, valid addresses a9ea0 (a23ea10 not output) cs7 not valid valid addresses a21ea0 (a23 and a22 not output) cs7 valid figure 8 10 memory map of area 7
128 hitachi 8.4 accessing external memory space in external memory space, strobe signal is output based on the assumption of a directly connected sram. the external memory space is allocated to the following areas: area 0 (when md2emd0 are 000 or 001) area 1 (when the dram enable bit (drame) of the bcr is 0) areas 2e4 area 5 (space where address a27 is 1) area 6 (when the multiplexed i/o enable bit (ioe) bit of the bcr is 0, or space where address a27 is 1) area 7 (space where address a27 is 0) 8.4.1 basic timing the bus cycle for external memory space access is 1 or 2 states. the number of states is controlled with the wait states by the settings of wait state control registers 1e3 (wcr1ewcr3). for details, see section 8.4.2., wait state control. figures 8.11 and 8.12 illustrate the basic timing of external memory space access. t1 ck a21ea0 csn rd (read) ad15ead0 (read) figure 8.11 basic timing of external memory space access (1-state read timing)
hitachi 129 t1 ck a21ea0 csn rd ad15ead0 t2 wrh , wrl ad15ead0 read write when rddty = 0 when rddty = 1 figure 8.12 basic timing of external memory space access (2-state read timing) high-level duties of 35% and 50% can be selected for the rd signal using the rd duty bit (rddty) of the bcr. when rddty is set to 1, the high-level duty is 35% of the t1 state, enabling longer access times for external devices. only set to 1 when the operating frequency is a minimum of 10 mhz. 8.4.2 wait state control the number of external memory space access states and the insertion of wait states can be controlled using the wcr1ewcr3 bits. the bus cycles that can be controlled are the cpu read cycle and the dmac dual mode read cycle. the bus cycle that can be controlled using the wcr2 is the dmac single-mode read/write cycle. table 8.8 shows the number of states and number of wait states in the access cycles to external memory spaces.
130 hitachi table 8.8 number of states and number of wait states in the access cycles to external memory spaces cpu read cycle, dmac dual mode read cycle, dmac single mode read/write cycle cpu write cycle and dmac dual mode write area corresponding bits in wcr1 and wcr2 = 0 corresponding bits in wcr1 and wcr2 = 1 cycle (cannot be controlled by wcr1)* 2 1, 3e5, 7 1 cycle fixed; wait signal ignored 2 cycles fixed + wait state from wait signal 0, 2, 6 (long wait available) 1 cycle + long wait state, wait signal ignored 1 cycle + long wait state* 1 + wait state from wait signal notes: 1. the number of long wait states is set by wcr3. 2. when drame = 1, short pitch/long pitch is selected with the ww1 bit of the wcr1. 3. pin wait cannot be used for the cs7 and wait pins of area 3 because they are multiplexed. for the cpu read cycle, dmac dual mode read cycle and dmac single mode read/write cycle, the access cycle is completed in 1 state when the corresponding bits of wcr1 and wcr2 for areas 1, 3e5, and 7 are cleared to 0 and the wait pin input signal is not sampled. when the bits are set to 1, the wait signal is sampled and the number of states is 2 plus the number of wait states in the wait signal. the wait signal is sampled at the rise of the system clock (ck) directly preceding the second state of the bus cycle and the wait states are inserted as long as the level is low. when a high level is detected, it shifts to the second state (final state). figure 8.13 shows the wait state timing when accessing the external memory spaces of areas 1, 3, 4, 5, and 7.
hitachi 131 t1 ck a21ea0 csn rd ad15ead0 wrh , wrl ad15ead0 read write wait tw (wait state) t2 figure 8.13 wait state timing for external memory space access (2 states plus wait states from wait signal) areas 0, 2 and 6 have long wait functions. when the corresponding bits in wcr1 and wcr2 are cleared to 0, the access cycle is 1 state plus the number of long wait states (set in wcr3, selectable between 1 and 4) and the wait pin input signal is not sampled. when the bits are set to 1, the wait signal is sampled and the number of states is 1 plus the number of long wait states plus the number of wait states in the wait signal. the wait signal is sampled at the rise of the system clock (ck) directly preceding the last long wait state and the wait states are inserted as long as the level is low. when a high level is detected, it shifts to the final long wait state. figure 8.14 shows the wait state timing when accessing the external memory spaces of areas 0, 2, and 6.
132 hitachi t1 ck a21ea0 csn rd ad15ead0 wrh , wrl ad15ead0 write wait wait states set in wcr3 wait state from wait signal input wait states set in wcr3 t lw1 t lw2 t w t lw3 read figure 8.14 wait state timing for external memory space access (1 state plus long wait state (when set to insert 3 states) plus wait states from wait signal) for cpu write cycles and dmac dual mode write cycles to external memory space, the number of states and wait state insertion cannot be controlled by wcr1. in areas 1, 3, 4, 5, and 7, the wait signal is sampled and the number of states is 2 plus the number of wait states in the wait signal (figure 8.13). in areas 0, 2 and 6, the number of states is 1 state plus the number of long wait states plus the number of wait states in the wait signal (figure 8.14). never write 0 in bits 7e2 and 0 of wcr1; only write 1. when area 1 is being used as external memory space, never write 0 to bit 1 (ww1); always write 1.
hitachi 133 8.4.3 byte access control the upper byte and lower byte control signals when 16-bit bus width space is being accessed can be selected from ( wrh , wrl , a0) or ( wr , hbs , lbs ). when the byte access select bit (bas) of the bcr is set to 1, the wrh , wrl , and a0 pins output wr , lbs and hbs signals. figure 8.15 illustrates the control signal output timing in the byte write cycle. t1 t2 t1 t2 ck a0 wrh wrl hbs lbs wr bas = 0 bas = 1 upper byte access lower byte access figure 8.15 byte access control timing for external memory space access (write cycle) the wrh , wrl system and the hbs , lbs system are available as byte access signals for the 16- bit space in the address/data multiplexing space and the external memory space. these strobe signals are assigned to pins in the manner: a0/ hbs , wrh / lbs , wrl / wr , and the bas bit of the bus control register (bcr) is used to switch specify signal sending. note that the byte access signals are strobe signals dedicated to byte access to a 16-bit space and not to be used for byte access to an 8-bit space. when making an access to an 8-bit space, use the a0/ hbs pin as a0 irrespective of the bas bit value (0 or 1) to use the wrl / wr pin as the wr pin, and avoid using the wrh / lbs pin.
134 hitachi 8.5 dram interface operation when the dram enable bit (drame) of the bcr is set to 1, area 1 becomes dram space and the dram interface function is available, which permits direct connection of this lsi to drams. 8.5.1 dram address multiplexing when the multiplex enable bit (mxe) of the dram area control register (dcr) is set to 1, row addresses and column addresses are multiplexed. this allows drams that require multiplexing of row and column addresses to be connected directly to the sh microprocessors without additional multiplexing circuits. when addresses are multiplexed (mxe = 1), setting of the dcr?s multiplex shift bits (mxc1, mxc0) allows selection of eight, nine and ten-bit row address shifting. table 8.9 illustrates the relationship between mxc1/mxc0 bits and address multiplexing.
hitachi 135 table 8.9 relationship between multiplex shift count bits (mxc1, mxc0) and address multiplexing shift amount 8 bits shift amount 9 bits shift amount 10 bits output pin output row address output column address output row address output column address output row address output column address a21 a21 a21 a21 a20 a20 a20 a20 a19 undefined a19 a19 a19 a18 value a18 undefined a18 a18 a17 a17 value a17 undefined a17 a16 a16 a16 value a16 a15 a23 a15 a15 a15 a14 a22 a14 a23 a14 a14 a13 a21 a13 a22 a13 a23 a13 a12 a20 a12 a21 a12 a22 a12 a11 a19 a11 a20 a11 a21 a11 a10 a18 a10 a19 a10 a20 a10 a9 a17 a9 a18 a9 a19 a9 a8 a16 a8 a17 a8 a18 a8 a7 a15 a7 a16 a7 a17 a7 a6 a14 a6 a15 a6 a16 a6 a5 a13 a5 a14 a5 a15 a5 a4 a12 a4 a13 a4 a14 a4 a3 a11 a3 a12 a3 a13 a3 a2 a10 a2 a11 a2 a12 a2 a1 a9 a1 a10 a1 a11 a1 a0 a8 a0 a9 a0 a10 a0 notes: the mxc1=1, mx0=1 setting is reserved. do not use it. for example, when mxc1 and mxc0 are set to 00 and an 8-bit shift is selected, the a23ea8 address bit values are output to pins a15ea0 as row addresses. the values for a21ea16 are undefined. the values of bits address a21ea0 are output to pins a21ea0 as column addresses. figure 8.16 depicts address multiplexing with an 8-bit shift.
136 hitachi a23 a8 a7 a0 a21 a16 a15 a0 a23 a22 a21 a0 a21 a0 ras = low level internal address address pin cas = low level internal address address pin undefined output figure 8.16 address multiplexing states (8-bit shift) 8.5.2 basic timing there are two types of dram accesses: short pitch and long pitch. short pitch or long pitch can be selected for the respective bus cycles using the rw1 and ww1 bits of wcr1 and the drw1 and dww1 bits of wcr2. when the corresponding bits are cleared to 0, dram access is short pitch and column address output occurs in 1 state. when these bits are 1, dram access is long pitch and column address output occurs in 2 states. figure 8.17 shows short pitch timing; figure 8.18 shows long pitch timing. the high-level duty of the cas signal can also be selected between 50% and 35% of the t c state when access is short pitch. by setting the cdty bit to 1, high level duty becomes 35% and dram access time can be lengthened. only set to 1 when the operating frequency is a minimum of 10 mhz.
hitachi 137 ck a21ea0 ras cas wrh , wrl ad15ead0 t p write wrh , wrl ad15ead0 read t r t c cdty = 0 cdty = 1 row address column address figure 8.17 short pitch access timing
138 hitachi ck a21ea0 ras cas wrh , wrl ad15ead0 t p write wrh , wrl ad15ead0 read t r t c 1 row address column address t c 2 figure 8.18 long pitch access timing 8.5.3 wait state control precharge state control: when the microprocessor clock frequency is raised and the cycle period shortened, 1 cycle may not always be sufficient for the precharge time for the ras signal when the dram is accessed. the bsc allows the precharge cycle to be set to 1 state or 2 states using the ras signal precharge cycles bit (tpc) of the dcr. when the tpc bit is 0, the precharge cycle is 1 state; when tpc is 1, the precharge cycle is 2 states. figure 8.19 shows the timing when the precharge cycle is 2 states.
hitachi 139 t p 1 t p 2 t r t c 1 t c 2 row address column address ck a21ea0 ras cas figure 8.19 precharge timing (long pitch) control of insertion of wait states using the wait pin input signal: the number of wait states inserted into the dram access cycle can be controlled by setting wcr1 and wcr2. when the corresponding bits in wcr1 and wcr2 are cleared to 0, the column address output cycle ends in 1 state and no wait states are inserted. when the bit is 1, the wait pin input signal is sampled on the rise of the system clock (ck) directly preceding the second state of the column address output cycle and the wait state is inserted as long as the level is low. when a high level is detected, it shifts to the second state. figure 8.20 shows the wait state timing in a long pitch bus cycle. t p t r t c 1 t cw (wait state) t c 2 row address column address ck a21ea0 ras cas wait figure 8.20 wait state timing during dram access (long pitch)
140 hitachi when the rw1 bit is set to 1, the number of wait states selected by cbr refresh wait state insertion bits 1 and 0 (rlw1, rlw0) of the refresh control register (rcr) are inserted into the cas-before-ras refresh cycle. 8.5.4 byte access control 16-bit width and 18-bit width drams require different types of byte control signals for access. by setting the dual cas signals/dual we signals select bit (cw2) in the dcr, the bsc allows selection of either the dual cas signals or the dual we signals system of control signals. when 16-bit space is being accessed and the cw2 bit is cleared to 0 for dual cas signals, cash , casl , and wrl signals are output; when cw2 is set to 1 for dual we signals, the casl , wrh , and wrl signals are output. when accessing 8-bit space, wrl and casl are output regardless of the cw2 setting. figure 8.21 shows the control timing of the upper byte write cycle (short pitch) in 16-bit space.
hitachi 141 t p t r t c row address column address ck a21ea0 ras cash casl wrh wrl byte control t p t r t c ck a21ea0 ras cash casl wrh wrl byte control row address column address high level fixed high level (a) dual cas signals (cw2 = 0) (a) dual we signals (cw2 = 1) high level fixed high level figure 8.21 byte access control timing for dram access (upper byte write cycle, short pitch)
142 hitachi 8.5.5 dram burst mode in addition to the normal mode of dram access, in which row addresses are output at every access and data then accessed (full access), the dram also has a high-speed page mode for use when continuously accessing the same row. the high speed page mode enables fast access of data simply by changing the column address after the row address is output (burst mode). select between full access and burst operation by setting the burst enable bit (be)) in the dcr. when the be bit is set to 1, burst operation is performed when the row address matches the previous dram access row address. figure 8.22 shows the comparison of full access and burst operation. ras cas ad15e ad0 ras cas a21ea0 ad15e ad0 a21ea0 row address 1 column address 1 row address 2 column address 2 data 1 data 2 row address 1 column address 1 column address 2 column address 3 column address 4 data 1 data 2 data 3 data 4 (a) full access (read cycle) (b) burst operation (read cycle) figure 8.22 full access and burst operation short pitch high-speed page mode or long pitch high-speed page mode burst transfers can be selected independently for dram read/write cycles even when the burst operation is selected by using the bits corresponding to area 1 in wcr1 and wcr2 (rw1, ww1, drw1, dww1). the ras down mode or ras up mode can be selected by setting the ras down bit (rasd) of the dcr when there is an access outside the dram space during burst operation.
hitachi 143 short pitch high-speed page mode and long pitch high-speed page mode: when burst operation is selected by setting the dcr?s be bit to 1, the short pitch high-speed page mode or long pitch high-speed page mode can be selected by setting the rw1, ww1, drw1, and dww1 bits of the wcr1 and wcr2. short-pitch, high-speed page mode: when the rw1, ww1, drw1 and dww1 bits in the wcr1 and wcr2 are cleared to 0, and the corresponding dram access cycle is continuing, the cas signal and column address output cycles continue as long as the row addresses continue to match. the column address output cycle is performed in 1 state and the wait signal is not sampled. figure 8.23 shows the read cycle timing for the short pitch high-speed page mode. t p t r t c t c ck a21e a0 ras cas data 4 data 3 data 2 data 1 t c t c wr ad15e a0 column address 1 column address 2 column address 3 column address 4 row address 1 figure 8.23 short pitch high-speed page mode (read cycle) when the write cycle continues for the same row address in the short pitch high-speed page mode, an open cycle (silent cycle) is produced for 1 cycle only. this timing is shown in figure 8.24. likewise, when a write cycle continues after the read cycle for the same row address, a silent cycle is produced for 1 cycle. this timing is shown in figure 8.25. note also that when dram is written to in short-pitch, high-speed page mode when using dmac single address mode, a silent cycle is inserted in each transfer. the details of timing are discussed in section 20.3.3, bus timing.
144 hitachi t p t r t c t c ck a21e a0 ras cas data b-2 data b-1 data a-2 data a-1 t c t c wr ad15e a0 silent cycle access a access b row address column address a-1 column address a-2 column address b-1 column address b-2 note: access a and b are examples of 32-bit data accesses in their respective 16-bit bus width spaces. figure 8.24 short pitch high-speed page mode (write cycle)
hitachi 145 t p t r t c t c ck a21e a0 ras cas t c t c wr ad15e ad0 silent cycle access a (read) access b (write) column address a-1 column address a-2 column address b-1 column address b-2 read data a-1 read data a-2 write data b-1 write data b-2 row address note: access a and b are examples of 32-bit data accesses in their respective 16-bit bus width spaces. figure 8.25 short pitch high-speed page mode (when read and write cycle continues with the same row address) the high-level duty of the cas signal can be selected in the short pitch high-speed page mode using the cas duty bit (cdty) in the dcr. when the cdty bit is cleared to 0, high-level duty is 50% of the tc state; when cdty is set to 1, it is 35% of the t c state. long-pitch, high-speed page mode: when the rw1, ww1, drw1, and dww1 bits in wcr1 and wcr2 are set to 1, and the corresponding dram access cycle is continuing, the cas signal and column address output cycles (2 states) continue as long as the row addresses continue to match. when the wait signal is detected at the low level, the second cycle of the column address output cycle is repeated as the wait state. figure 8.26 shows the timing for the long pitch high-speed page mode. see section 20.3.3, bus timing, for more information about the timing.
146 hitachi t p t r t c 1 t c 2 ck a21ead0 ras cas column address 1 data 1 wr ad15ead0 column address 2 t c 1t c 2 data 2 data 1 data 2 read wr ad15ead0 write row address 1 figure 8.26 long pitch high-speed page mode (read/write cycle) ras down mode and ras up mode: sometimes access to another area can occur between accesses to the dram even though burst operation has been selected. keeping the ras signal at low while this other access is occurring allows burst operation to continue the next time the same row of the dram is accessed. the rasd bit in the dcr selects the ras down mode when set to 1 and the ras up mode when cleared to 0. in both ras down mode and ras up mode, burst operation is continued while the same row address continues to be accessed, even if the bus master is changed. ras down mode: when the rasd bit of dcr is set to 1, the dram access pauses and the ras signal is held low throughout the access of the other space while waiting for the next access to the dram area. when the row address for the next dram access is the same as the previous dram access, burst operation continues. figure 8.27 shows the timing of the ras down mode when external memory space is accessed during burst operation. the ras signal can be held down in the dram for a limited time; the ras signal must be returned to high within the specified limits even when the ras down mode is selected since the critical low level period is set. in this lsi, even when the ras down mode is selected, the ras signal automatically reverts to high when the dram is refreshed, so the bsc?s refresh control function can be employed to set a cas-before-ras refresh that will keep operation within specifications. see section 8.5.6, refresh control, for details.
hitachi 147 t p t r t c t c ck a21e a0 ras cas data 1 wr ad15e ad0 t1 dram access dram access external memory space access t c t c data 2 data 3 data 4 column address 1 external memory data column address 2 external memory column address 3 column address 4 row address figure 8.27 ras down mode ras up mode: when the rasd bit is cleared to 0, the ras signal reverts to high whenever a dram access pauses for access to another space. burst operation continues only while dram access is continuous. figure 8.28 shows the timing when an external memory space access occurs during burst operation in the ras up mode.
148 hitachi t p t r t c t c ck a21e a0 ras cas data 1 ad15e ad0 t1 dram access dram access external memory space access t c t r data 2 data 3 t p row address row address external memory data column address 1 column address 2 external memory address column address 3 figure 8.28 ras up mode 8.5.6 refresh control the bsc has a function for controlling dram refreshing. by setting the refresh mode bit (rmode) in the refresh control register (rcr), either cas-before-ras refresh (cbr) or self- refresh can be selected. when no refresh is performed, the refresh timer counter (rtcnt) can be used as an 8-bit interval timer. cas-before-ras refresh (cbr): a refresh is performed at an interval determined by the input clock selected in the clock select bits 2e0 (cks2ecks0) of the refresh timer control/status register (rtcsr) and the value set in the refresh time constant register (rtcor). set the values of rtcor and cks2ecks0 so they satisfy the refresh interval specifications of the dram being used. to perform a cbr refresh, clear the rmode bit of the rcr to 0 and then set the refresh control bit (rfshe) bit to 1. also write in the required values to rtcnt and rtcor. when the clock is thereafter selected in the cks2ecks0 bits of the rtcsr, the rtcnt will begin to increment from its current value. the rtcnt value is constantly compared to the rtcor value and the cbr refresh is performed when they match. the rtcnt is simultaneously cleared to h'00 and incrementing begins again. when the clock is selected in the cks2ecks0 bits, the rtcnt immediately begins to increment from its current value. this means that when the rtcor cycle is set after the cks2ecks0 bits are set, the rtcnt count may already be higher than the rtcor cycle. when this occurs, the rtcnt will overflow once (h'ff goes to h'00) and incrementing will start again. since the cbr
hitachi 149 refresh will not be performed until the rtcnt again matches the rtcor value, the initial refresh interval will be rather long. it is thus advisable to set the rtcor cycle prior to setting the cks2e cks0 bits and start it incrementing. when cbr refresh control is being performed after its use as an 8-bit interval timer, the rtcnt count value may be in excess of the refresh cycle. for this reason, clear the rtcnt by writing h'00 before starting refresh control to assure a correct refresh interval. when the rw1 bit of wcr1 is set to 1 and the read cycle is set to long pitch, the number of wait states selected by the rlw1 and rlw0 bits of the rcr will be inserted into the cbr refresh cycle, regardless of the status of the wait signal. figure 8.29 shows the rtcnt operation and figure 8.30 shows the timing of the cbr refresh. for details on timing, see section 20.3.3, bus timing. cbr cbr cbr cbr clock selected with cks2ecks0 h'00 rtcor value rtcnt value compare match with rtcor compare match with rtcor compare match with rtcor compare match with rtcor cbr: cas-before-ras refresh time figure 8.29 refresh timer counter (rtcnt) operation t rp t rr t rc ck ras cas figure 8.30 output timing for cas-before-ras refresh signal self-refresh mode: some drams have a self-refresh mode (parity back-up mode). this is a type of a standby mode in which the refresh timing and refresh addresses are generated inside the dram chip. when the rfshe and rmode bits of the rcr are both set to 1, the dram will
150 hitachi enter the self-refresh mode when the cas and ras signals are output as shown in figure 8.31. see section 20.3.3, bus timing, for details. the dram self-refresh mode is cleared when the rmode bit in the rcr is cleared to 0 (figure 8.31). the rfshe bit should be left at 1 when this is done. some dram vendors recommend that after exiting the self-refresh mode, all row addresses should be refreshed again. this can be done using the bcr?s cbr refresh function to set all row addresses for refresh in software. to access a dram area in the self-refresh mode, clear the rmode bit to 0 and exit the self- refresh mode. the lsi can be kept in the self-refresh state and shifted to standby mode by setting it to self- refresh mode, setting the standby bit (sby) of the standby control register (sbycr) to 1, and then executing a sleep instruction. t rp t rr ck ras cas t rc t rcc figure 8.31 output timing of self-refresh signal refresh requests and bus cycle requests: when a cas-before-ras refresh or self-refresh is requested during bus cycle execution, parallel execution is sometimes possible. table 8.10 describes operation when the refresh and bus cycle are in contention.
hitachi 151 table 8.10 refresh and bus cycle contention type of bus cycle external space access type of external memory space, multiplexed i/o space dram space on-chip rom, on-chip ram , on-chip refresh read cycle write cycle read cycle write cycle peripheral access cas-before- ras refresh yes no no no yes self-refresh yes yes no no yes yes: can be executed in parallel no: cannot be executed in parallel when parallel execution is available, the ras and cas signals are output simultaneously during bus cycle execution and the refresh is executed. when parallel execution is not available, refresh occurs after the bus cycle has ended. using rtcnt as an 8-bit interval timer: when not performing refresh control, rtcnt can be used as an 8-bit interval timer. simply set the rfshe bit of the rcr to 0. to produce a compare match interrupt (cmi), set the compare match interrupt enable bit (cmie) to 1 and set the interrupt generation timing in rtcor. when the input clock is selected with the cks2ecks0 bits of the rtcsr, rtcnt starts incrementing as an 8-bit interval timer. its value is constantly being compared to rtcor and when a match occurs, the cmf bit of rtcsr is set to 1 and a cmi interrupt is produced. rtcnt is cleared to h'00. when the clock is selected with cks2ecks0 bits, rtcnt starts incrementing immediately. this means that when the rtcor cycle is set after the cks2ecks0 bits are set, the rtcnt count may already be higher than the rtcor cycle. when this occurs, the rtcnt will overflow once (h'ff goes to h'00) and the count up will start again. no interrupt will be generated until the rtcnt again matches the rtcor value. it is thus advisable to set the rtcor cycle prior to setting the cks2ecks0 bits. after its use as an 8-bit interval timer, the rtcnt count value may be in excess of the set cycle. for this reason, write h'00 to the rtcnt to clear it before starting to use it again with new settings. rtcnt can then be restarted and an interrupt obtained after the correct interval. 8.6 address/data multiplexed i/o space access the bsc is equipped with a function that multiplexes input/output of address and data to pins ad15ead0 in area 6. this allows the sh microprocessor to be directly connected to peripheral lsis that required address/data multiplexing.
152 hitachi 8.6.1 basic timing when the multiplexed i/o enable bit (ioe) of the bcr is set to 1, the area 6 space with address bit a27 as 0 (h'6000000eh'6ffffff) becomes an address/data multiplexed i/o space that, when accessed, multiplexes addresses and data. when the a14 address bit is 0, the bus width is 8 bits and address output and data input/output are performed from the ad7ead0 pins. when the a14 address bit is 1, the bus width is 16 bits and address output and data input/output are performed from the ad15ead0 pins. in the address/data multiplexed i/o space, access is controlled with the ah , rd and wr signals. accesses in the address/data multiplexed i/o space is performed in 4 states, regardless of the wcr settings. figure 8.32 shows the timing when the address/data multiplexed i/o space is accessed. t1 ck a21ea0 cs ah address ad15ead0 data (input) address data (output) rd read ad15ead0 wrh , wrl write t2 t3 t4 figure 8.32 access timing for address/data multiplexed i/o space the high-level duty of the rd signal can be selected between 35% and 50% using the rd duty bit (rddty) of the bcr. when rddty is 1, the high-level duty is 35% of the t3 or tw state, lengthening the access time for external devices.
hitachi 153 8.6.2 wait state control when the address/data multiplexed i/o space is accessed, the wait pin input signal is sampled and a wait state inserted whenever a low level is detected, regardless of the setting of the wcr. figure 8.33 shows an example in which a wait signal causes a wait state of 1 state to be inserted. t1 ck a21ea0 cs ah address ad15ead0 address data (output) rd read ad15ead0 wrh, wrl write t2 tw (wait state) t3 t4 wait data (input) figure 8.33 wait state timing for address/data multiplexed i/o space access 8.6.3 byte access control the byte access control signals when the address/data multiplexed i/o space is being accessed are of two types ( wrh , wrl , a0, or wr , hbs , lbs ), just as for byte access control of external memory space access. these types can be selected using the bas bit of the bcr. see section 8.4.3, byte access control, for details.
154 hitachi 8.7 parity check and generation the bsc can check and generate parity for data input and output to or from in the dram space of area 1 and the external memory space of area 2. to check and generate parity, select the space (dram space only, or dram space and area 2) for which parity is to be checked and generated using the parity check enable bits (pchk1 and pchk0) of the parity control register and select odd or even parity in the parity polarity bit (peo). when data is input from the space selected in the pchk1 and pchk0 bits, the bsc checks the peo bit to see if the polarity of the dph pin input (upper byte parity data) is accurate for the ad15ead8 pin input (upper byte data) or if the dpl pin input (lower byte parity data) is accurate for the ad7ead0 pin input (lower byte data). if the check indicates that either the upper or lower byte parity is incorrect, a parity error interrupt is produced (pei). when outputting data to the space selected in the pchk1 and pchk0 bits, the bsc outputs parity data output of the polarity set in the peo bit from the dph pin for the ad15ead8 pin output (upper byte data) or from the dpl pin for the ad7ead0 pin input (lower byte data) using the same timing as the data output. the bsc is also able to force a parity output for use in testing the system?s parity error check function. when the parity force output bit (pfrc) of the pcr is set to 1, a high level is forcibly output from the dph and dpl pins when data is output to the space selected in the pchk1 and pchk0 bits. 8.8 warp mode in warp mode, an external write cycle or dma single address mode transfer cycle and an internal access cycle (read/write to on-chip memory or on-chip peripheral modules) operate independently in parallel. the warp mode is entered by setting the warp mode bit (warp) in the bcr to 1. this allows the lsi to be operated at high speed. when in the warp mode an external write cycle or dma single address mode transfer cycle continues for at least 2 states and their is an internal access, only the external write cycle will be performed in the initial state. the external write cycle and internal access cycle will be performed in parallel from the next state on, without waiting for the end of the external write cycle. figure 8.34 shows the timing when an access to an on-chip peripheral module and an external write cycle are performed in parallel.
hitachi 155 t1 ck a21e a0 csn wr t2 t3 t4 t5 external space writing on-chip peripheral module read/write ad15e ad0 external space write internal address internal write strobe internal data bus internal read strobe internal data bus on-chip peri- pheral module write on-chip peri- pheral module read external space address write data external space address write data read data on-chip peripheral module address figure 8.34 warp mode timing (access to on-chip peripheral module and external write cycle) 8.9 wait state control the wcr1ewcr3 registers of the bsc can be set to control sampling of the wait signal when accessing various areas and the number of bus cycle states. table 8.11 shows the number of bus cycle states when accessing various areas.
156 hitachi table 8.11 bus cycle states when accessing address spaces cpu read cycle, dmac dual mode read cycle, dmac single mode memory read/write cycle address space corresponding bits in wcr1 and wcr2 = 0 corresponding bits in wcr1 and wcr2 = 1 external memory (areas 1,3e5, 7) 1 state fixed; wait signal ignored 2 states + wait states from wait signal external memory (areas 0,2, 6; long wait avail- able) 1 state + long wait state*, wait signal ignored 1 state + long wait state* + wait states from wait signal dram space (area 1) column address cycle: 1 state, wait signal ignored (short pitch) column address cycle: 2 states + wait states from wait signal (long pitch) multiplexed i/o space (area 6) 4 states + wait states from wait signal on-chip peripheral mod- ule space (area 5) 3 states fixed, wait signal ignored on-chip rom (area 0) 1 state fixed, wait signal ignored on-chip ram (area 7) 1 state fixed, wait signal ignored cpu write cycle, dmac dual mode memory write cycle address space ww1 of wcr1 = 0 ww1 of wcr1 =1 external memory (areas 1, 3e5, 7) 2 states + wait states from wait signal external memory (areas 0, 2, 6; long wait available) 1 state + long wait state* + wait states from wait signal dram space (area 1) column address cycle: 1 state, wait signal ignored(short pitch) column address cycle: 2 states + wait states from wait signal (long pitch) multiplexed i/o space (area 6) 4 states + wait states from wait signal on-chip peripheral module space (area 5) 3 states fixed, wait signal ignored on-chip rom (area 0) 1 state fixed, wait signal ignored on-chip ram (area 7) 1 state fixed, wait signal ignored note: the number of long wait states (1 to 4) is set in wcr3.
hitachi 157 for details on bus cycles when external spaces are accessed, see section 8.4, external memory space access, section 8.5, dram space access, and section 8.6, address/data multiplexed i/o space access. accesses of on-chip spaces are as follows: on-chip peripheral module spaces (area 5 when address bit a27 is 1) are always 3 states, regardless of the wcr, with no wait signal sampling. accesses of on-chip rom (area 0 when md2emd0 are 010) and on-chip ram (area 7 when address bit a27 is 0) are always performed in 1 state, regardless of the wcr, with no wait signal sampling. if the bus timing specifications (t wts and t wth ) are not observed when the wait signal is input in external space access, this will simply mean that wait signal assertion and negation will not be detected, but will not result in misoperation. note, however, that the inability to detect wait signal assertion may result in a problem with memory access due to insertion of an insufficient number of waits. 8.10 bus arbitration the superh microcomputer can release the bus to external devices when they request the bus. it has two internal bus masters, the cpu and the dmac. priorities for releasing the bus for these two are as follows. bus request from external device > refresh > dmac > cpu thus, an external device has priority when it generates a bus request, even when the dmac is doing a burst transfer. note that when a refresh request is generated while the bus is released to an external device, back becomes high level and the bus right can be acquired to perform the refresh upon receipt of a breq = high level response from the external device. input all bus requests from external devices to the breq pin. the signal indicating that the bus has been released is output from the back pin. figure 8.35 illustrates the bus release procedure.
158 hitachi bus released breq received bus acquisition breq = low back = low acknowledge back bus request external device superh bus release response address, data, strobe pin: high impedance strobe pin: high-level output figure 8.35 bus release procedure 8.10.1 the operation of bus arbitration this lsi has the bus arbitration function which can give bus ownership to an external device when the device requests the bus ownership. when breq is input and the bus cycle being executed by the cpu or dmac is completed, back becomes low and a bus is released for an external device. at this time, the following operates when bus arbitration conflicts with refresh. 1. if dram refresh is requested in this lsi when a bus is released and back is low, back becomes high and the occurrence of the refresh request can be informed externally. at this time, the external device may generate a bus cycle when breq is low even if back is high. therefore, a bus remains released to the external device. then, when breq becomes high, this lsi gets bus ownership, and executes refresh and the bus cycle of the cpu or dmac. after the external device gets bus ownership and back is low, refresh is requested when back becomes high even if the low level of breq is input. therefore, turn breq high immediately to release a bus for this lsi to hold dram data (see figure 8.36). 2. when breq changes from high to low and internal refresh is requested at the timing of the bus release of this lsi, back may remain high (do not become low). a bus is released to the external device since the low level of breq is input. this operation is based on the above specification (1). to hold dram data, turn breq high and release a bus to this lsi immediately when the external device detects that back does not change to low during a fixed time this lsi (see figure 8.37). when a refresh request is generated and back returns to high, as shown in figure 8.37, a momentary narrow pulse-shaped spike may be output where back was originally supposed to become low.
hitachi 159 back breq refresh damand refresh execution figure 8.36 back operation by refresh demand (1) back breq if back has not gone low after waiting for the maximum number of states * before the superh releases the bus, return breq to the high level. note: * for details see section 8.11.3, maximum number of states from breq input to bus release. back does not go low. refresh request figure 8.37 back operation in response to refresh request (2) 8.10.2 back operation 1. back operation when an internal refresh is requested during an attempt to assert the back signal and back is not asserted but remains high, a momentary narrow pulse-shaped spike may be output, as shown below. back breq refresh demand pulse width of the spike is approx. 2 to 5 ns.
160 hitachi 2. countermeasure against a spike on the back signal the following describes the countermeasure against a spike on the back signal: a. when breq is input to release the bus of the lsi, make sure that conflicts with a refresh operation do not occur. stop the refresh operation or operate the refresh timer counter (rtcnt) or the refresh time constant register (rtcor) of the bus controller (bsc) to shift the refresh timing. b. the spike on the back signal has a narrow pulse width of approximately 2 to 5 ns, which can be eliminated by using a capacitor as shown in the figure below. for example, adding a capacitance of 220 pf can raise the minimum voltage of the spike above 2.0 v. note that delay of the back signal increases approximately in units of 0.1 ns/pf. (when a capacitance of 220 pf is added, the delay increases approximately by 22 ns. back superh microcomputer c capacitor-incorporating circuit for eliminating a spike c. latching the back signal by using a flip-flop or triggering the flip-flop may be successful or unsuccessful due to the narrow pulse width of the spike. implement a circuit configuration which will cause no problems when latching back or using back as a trigger signal. when splitting the back signal into two signals and latching each of them using the flip- flop or triggering the flip-flop, the flip-flop may operate for one signal but may not for another. to capture the back signal using the flip-flop, receive the back signal using a single flip-flop then distribute the signal (see figure below).
hitachi 161 back dq q dq q back dq q trigger ok trigger ng 8.11 usage notes 8.11.1 usage notes on manual reset condition: when dram (long-pitch mode) is used and manual reset is performed. the low width of ras output may be shorter than usual in rese + (2.5tcyc ? 1.5tcyc), causing the specified value (tras) of dram not to be satisfied. corresponding dram conditions: long pitch/normal mode long pitch/high-speed page mode there are no problems regarding operations except for the above conditions. there are the following four cases (figure 8.38 to figure 8.41) for the output states of dram control signals ( ras , cas , and wr ) corresponding to res latch timing. actual output levels are shown by solid lines (not by dashed lines).
162 hitachi ck res a0 to a21 ras cas wr ad0 to ad15 row address res latch timing tp tr tc1 tc2 data output manual reset colum address ffff figure 8.38 long - pitch mode write (1) row address res latch timing tp tr tc1 tc2 data output manual reset ck res a0 to a21 ras cas wr ad0 to ad15 ffff figure 8.39 long - pitch mode write (2)
hitachi 163 rd tp tr tc1 tc2 manual reset ck res a0 to a21 ras cas colum address res latch timing row address ffff figure 8.40 long - pitch mode read (1) tp tr tc1 tc2 manual reset rd ck res a0 to a21 ras cas res latch timing row address ffff figure 8.41 long - pitch mode read (2) for the signal output shown by solid lines, dram data may not be held. therefore, when dram data must be held after reset, take one of the coutermeasures described as follows. 1. when resetting manually, do this in watchdog timer (wdt) condition. 2. even if the low width of ras becomes as short as 1.5 tcyc as shown above, use with a frequency that satisfies the dram standard (tras). 3. even in case the low width of ras has become 1.5 tcyc, proceed by using the external circuit so that a ras signal with a low width of 2.5 tcyc is input in the dram (in case the low width of ras is higher than 2.5 tcyc, operate so that the current waveform is input in the dram).
164 hitachi the countermeasures are not required when dram data is initialized or loaded again after manual reset. 8.11.2 usage notes on parity data pins dph and dpl the following specifies the setup time tds of the parity dada dph and dpl to cas signal rising when the parity dada dph and dpl are written to dram in long-pitch mode (early write). table 8.12 setup time of parity data dph and dpl item symbol min data setup time to cas (for only dph and dpl in long-pitch mode) tds e5 ns therefore, when writing parity data dph and dpl to the dram in long-pitch mode, delay the wrh and wrl signals of this lsi and write with delayed writing. nomal dada is also delayed-written, causing no problems. superh ras cas rd we ck dq q ras cas dram wrh or wrl dwrh or dwrl *2 * 1 * 1 * 1: for preventing signal racing * 2: negative edge latch oe microcomputer figure 8.42 delayed-write control circuit 8.11.3 maximum number of states from breq input to bus release the maximum number of states from breq input to bus release is: maximum number of states for which bus is not released + approx. 4.5 states note: breakdown of approx. 4.5 states: 1.5 states: until back output after end of bus cycle 1 state (min.): tbacd1 1 state (max.): tbrqs 1 state: sampling in 1 state before end of bus cycle
hitachi 165 breq is sampled one state before the bus cycle. if breq is input without satisfying tbrqs, the bus is released after executing cycle b following the end of bus cycle a, as shown in figure 8.43. the maximum number of states from breq input to bus release are used when b is a cycle comprising the maximum number of states for which the bus is not released; the number of states is the maximum number of states for which bus is not released + approx. 4.5 states. the maximum number of states for which the bus is not released requires careful investigation. ck breq bus cycle back tbrqs b a tbacd1 bus release figure 8.43 when breq is input without satisfying tbrqs 1. cycles in which bus is not released (a) one bus cycle the bus is never released during one bus cycle. for example, in the case of a longword read (or write) in 8-bit ordinary space, one bus cycle consists of 4 memory accesses to 8-bit ordinary space, as shown in figure 8.44. the bus is not released between these accesses. assuming one memory access to require 2 states, the bus is not released for a period of 8 states. 8 bits 8 bits cycle during which bus is not released 8 bits 8 bits figure 8.44 one bus cycle (b) tas instruction read cycle and write cycle the bus is never released during a tas instruction read cycle and write cycle (figure 8.45). the tas instruction read cycle and write cycle should be regarded as one bus cycle during which the bus is not released.
166 hitachi read cycle cycle during which bus is not released (1 bus cycle) write cycle figure 8.45 tas instruction read cycle and write cycle (c) refresh cycle + bus cycle the bus is never released during a refresh cycle and the following bus cycle ((a) or (b) above)) (figure 8.46). refresh cycle cycle during which bus is not released 1 bus cycle figure 8.46 refresh cycle and following bus cycle
hitachi 167 2. bus release procedure the bus release procedure is shown in figure 8.47. figure 8.47 shows the case where breq is input one state before the break between bus cycles so that tbrqs is satisfied. in the sh7020 and sh7021, the bus is released after the bus cycle in which breq is input (if breq is input between bus cycles, after the bus cycle starting next). ck a21 to a0 breq back rd, wr ras, cas csn t brqs t brqs t bzd t bzd t bacd1 t bacd1 bus cycle bus cycle bus release strobe pin: high-level output the bus is released after the bus cycle in which breq is input (if breq is input between bus cycles, after the bus cycle starting next). bus cycle restart address & data strobe pins: high impedance figure 8.47 bus release procedure
hitachi 169 section 9 direct memory access controller (dmac) 9.1 overview the superh microprocomputer chip includes a four-channel direct memory access controller (dmac). the dmac can be used in place of the cpu to perform high speed transfers between external devices that have dack (transfer request acknowledge signal), external memory, memory-mapped external devices, on-chip memory and on-chip peripheral modules (excluding the dmac itself). using the dmac reduces the burden on the cpu and increases overall operating efficiency. 9.1.1 features the dmac has the following features. four channels four gbytes of address space on the architecture byte or word selectable data transfer unit 65536 transfers (maximum) single address mode transfers (channels 0 and 1): either the transfer source or transfer destination (peripheral device) is accessed by a dack signal (selectable) while the other is accessed by address. 1 transfer unit of data is transferred in each bus cycle. device combinations able to transfer: ? external devices with dack and memory-mapped external devices (including external memories) ? external devices with dack and memory-mapped external memories dual address mode transfer: (channels 0?): both the transfer source and transfer destination are accessed by address. 1 transfer unit of data is transferred in 2 bus cycles. device combinations able to transfer: ? two external memories ? external memory and memory-mapped external devices ? two memory-mapped devices ? external memory and on-chip memory ? memory-mapped external devices and on-chip peripheral module (excluding the dmac itself) ? external memory and on-chip memory ? memory-mapped external device and on-chip peripheral module (excluding the dmac) ? two on-chip memories ? on-chip memory and on-chip peripheral modules (excluding dmac)
170 hitachi ? two on-chip peripheral modules (excluding dmac) transfer requests ? external request (from dreq pins (channels 0 and 1 only). dreq can be detected either by edge or by level) ? requests from on-chip peripheral modules (serial communications interface (sci), and 16- bit integrated-timer pulse unit (itu)) ? auto-request (the transfer request is generated automatically within the dmac) selectable bus modes: cycle-steal mode or burst mode selectable channel priority levels: fixed, round-robin, or external-pin round-robin modes cpu can be asked for interrupt when data transfer ends maximum transfer rate ? 20 m words/s (320 mb/s) for 5v and 20 mhz bus mode: burst mode transmit size: word 9.1.2 block diagram figure 9.1 is a block diagram of the dmac.
hitachi 171 dreq0 , dreq1 itu sci dack0, dack1 dein dmac on-chip rom on-chip ram on-chip peripheral module peripheral bus external bus external rom external ram external device (memory mapped) external device (with acknowledge) bus controller iteration control register control start-up control request priority control bus interface dmac module bus sarn darn tcrn chcrn dmaor internal bus dmaor: dma operation register sarn: dma source address register darn: dma destination address register tcrn: dma transfer count register chcrn: dma channel control register dein: dma transfer-end interrupt request to cpu. n: 0? figure 9.1 dmac block diagram
172 hitachi 9.1.3 pin configuration table 9.1 shows the dmac pins. table 9.1 pin configuration channel name symbol i/o function 0 dma transfer request dreq0 i dma transfer request input from external device to channel 0 dma transfer request acknowledge dack0 o dma transfer request acknowledge output from channel 0 to external device 1 dma transfer request dreq1 i dma transfer request input from external device to channel 1 dma transfer request acknowledge dack1 o dma transfer request acknowledge output from channel 1 to external device
hitachi 173 9.1.4 register configuration table 9.2 summarizes the dmac registers. dmac has a total of 17 registers. each channel has four control registers. one other control register is shared by all channels table 9.2 dmac registers chan- nel name abbre- viation r/w initial value address access size 0 dma source address register 0 sar0* 3 r/w undefined h'5ffff40 16, 32 dma destination address register 0 dar0* 3 r/w undefined h'5ffff44 16, 32 dma transfer count register 0 tcr0* 3 r/w undefined h'5ffff4a 16, 32 dma channel control register 0 chcr0 r/(w)* 1 h'0000 h'5ffff4e 8, 16, 32 1 dma source address register 1 sar1* 3 r/w undefined h'5ffff50 16, 32 dma destination address register 1 dar1* 3 r/w undefined h'5ffff54 16, 32 dma transfer count register 1 tcr1* 3 r/w undefined h'5ffff5a 16, 32 dma channel control register 1 chcr1 r/(w)* 1 h'0000 h'5ffff5e 8, 16, 32 2 dma source address register 2 sar2* 3 r/w undefined h'5ffff60 16, 32 dma destination address register 2 dar2* 3 r/w undefined h'5ffff64 16, 32 dma transfer count register 2 tcr2* 3 r/w undefined h'5ffff6a 16, 32 dma channel control register 2 chcr2 r/(w)* 1 h'0000 h'5ffff6e 8, 16, 32 3 dma source address register 3 sar3* 3 r/w undefined h'5ffff70 16, 32 dma destination address register 3 dar3* 3 r/w undefined h'5ffff74 16, 32 dma transfer count register 3 tcr3* 3 r/w undefined h'5ffff7a 16, 32 dma channel control register 3 chcr3 r/(w)* 1 h'0000 h'5ffff7e 8, 16, 32 shared dma operation register dmaor r/(w)* 2 h'0000 h'5ffff48 8, 16, 32 notes: 1. write 0 alone in bit 1 of chcr0?hcr3 to clear flags. 2. write 0 alone in bits 1 and 2 of the dmaor to clear flags. 3. access sar0?ar3, dar0?ar3, and tcr0?cr3 by long word or word. if byte access is used when writing, the value of the register contents becomes undefined; if used when reading, the value read is undefined.
174 hitachi 9.2 register descriptions 9.2.1 dma source address registers 0? (sar0?ar3) dma source address registers 0? (sar0?ar3) are 32-bit read/write registers that specify the source address of a dma transfer. during a dma transfer, these registers indicate the next source address (in single-address mode, sar is ignored in transfers from external devices with dack to memory-mapped external devices or external memory). the initial value after resets or in standby mode is undefined. bit: 31 30 29 28 27 26 25 24 bit name: initial value: r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 23 22 21 20 0 bit name: initial value: r/w: r/w r/w r/w r/w r/w 9.2.2 dma destination address registers 0? (dar0?ar3) dma destination address registers 0? (dar0?ar3) are 32-bit read/write registers that specify the destination address of a dma transfer. during a dma transfer, these registers indicate the next destination address (in single-address mode, dar is ignored in transfers from memory- mapped external devices or external memory to external devices with dack). the initial value after resets or in standby mode is undefined. bit: 31 30 29 28 27 26 25 24 bit name: initial value: r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 23 22 21 20 0 bit name: initial value: r/w: r/w r/w r/w r/w r/w
hitachi 175 9.2.3 dma transfer count registers 0? (tcr0?cr3) dma transfer count registers 0-3 (tcr0?cr3) are 16-bit read/write registers that specify the dma transfer count (bytes or words). the number of transfers is 1 when the setting is h'0001, 65535 when the setting is h'ffff and 65536 (the maximum) when h'0000 is set. during a dma transfer, these registers indicate the remaining transfer count. the initial value after resets or in standby mode is undefined. bit: 15 14 13 12 11 10 9 8 bit name: initial value: r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: r/w: r/w r/w r/w r/w r/w r/w r/w r/w 9.2.4 dma channel control registers 0? (chcr0?hcr3) dma channel control registers 0? (chcr0?hcr3) are 16-bit read/write registers that control the dma transfer mode. they also indicate dma transfer status. they are initialized to h'0000 by a reset or standby mode. bit: 15 14 13 12 11 10 9 8 bit name: dm1 dm0 sm1 sm0 rs3 rs2 rs1 rs0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: am al ds tm ts ie te de initial value: 0 0 0 0 0 0 0 0 r/w: r/(w) *2 r/(w) *2 r/(w) *2 r/w r/w r/w r/(w)* r/w notes: 1. write only 0 to clear the flag. 2. writing is effective only for chcr0 and chcr1.
176 hitachi bits 15 and 14 (destination address mode bits 1, 0 (dm1 and dm0)): dm1 and dm0 select whether the dma destination address is incremented, decremented, or left fixed (in the single address mode, dm1 and dm0 are ignored when transfers are made from memory-mapped external devices or external memory to external devices with dack). dm1 and dm0 are initialized to 00 by resets or in standby mode. bit 15: dm1 bit 14: dm0 description 0 0 fixed destination address (initial value) 0 1 destination address is incremented (+1 or +2 depending on if the transfer size is word or byte) 1 0 destination address is decremented (? or ? depending on if the transfer size is word or byte) 1 1 reserved (illegal setting) bits 13 and 12 (source address mode bits 1, 0 (sm1 and sm0)): sm1 and sm0 select whether the dma source address is incremented, decremented, or left fixed (in the single address mode, sm1 and sm0 are ignored when transfers are made from external devices with dack to memory-mapped external devices or external memory). sm1 and sm0 are initialized to 00 by resets or in standby mode. bit 13: sm1 bit 12: sm0 description 0 0 fixed source address (initial value) 0 1 source address is incremented (+1 or +2 depending on if the transfer size is word or byte) 1 0 source address is decremented (? or ? depending on if the transfer size is word or byte) 1 1 reserved (illegal setting) bits 11? (resource select bits 3? (rs3-rs0)): rs3?s0 specify which transfer requests will be sent to the dmac. do not change the transfer request source unless the dma enable bit (de) is 0. the rs3?s0 bits are initialized to 0000 by resets or in standby mode.
hitachi 177 bit 11: rs3 bit 10: rs2 bit 9: rs1 bit 8: rs0 description 00 00 dreq (external request* 1 , dual address mode) (initial value) 0 0 0 1 reserved (illegal setting) 00 10 dreq (external request* 1 , single address mode* 2 ) 00 11 dreq (external request* 1 , single address mode* 3 ) 0 1 0 0 rxi0 (on-chip serial communication interface 0 receive data full interrupt transfer request)* 4 0 1 0 1 txi0 (on-chip serial communication interface 0 transmit data empty interrupt transfer request)* 4 0 1 1 0 rxi1 (on-chip serial communication interface 1 receive data full interrupt transfer request)* 4 0 1 1 1 txi1 (on-chip serial communication interface 1 transmit data empty interrupt transfer request)* 4 1 0 0 0 imia0 (on-chip itu0 input capture/compare-match a interrupt transfer request)* 4 1 0 0 1 imia1 (on-chip itu1 input capture/compare-match a interrupt transfer request)* 4 1 0 1 0 imia2 (on-chip itu2 input capture/compare-match a interrupt transfer request)* 4 1 0 1 1 imia3 (on-chip itu3 input capture/compare-match a interrupt transfer request)* 4 1 1 0 0 auto-request (transfer requests automatically generated within dmac)* 4 1 1 0 1 reserved (illegal setting) 1 1 1 0 reserved (illegal setting) 1 1 1 1 reserved (illegal setting) sci0, sci1: serial communications interface channels 0 and 1. itu0?tu3: channels 0? of the 16-bit integrated-timer pulse unit. notes: 1. these bits are valid only in channels 0 and 1. none of these request sources can be selected in channels 2 and 3. 2. transfer from memory-mapped external device or external memory to external device with dack. 3. transfer from external device with dack to memory-mapped external device or external memory. 4. dual address mode.
178 hitachi bit 7 (acknowledge mode bit (am)): in the dual address mode, am selects whether the dack signal is output during the data read cycle or write cycle. this bit is valid only in channels 0 and 1. the am bit is initialized to 0 by resets or in standby mode. the am bit is not valid in single address mode. bit 7: am description 0 dack is output in read cycle (initial value) 1 dack is output in write cycle bit 6 (acknowledge level bit (al)): al selects active high signal or active low signal for the dack signal. this bit is valid only in channels 0 and 1. the al bit is initialized to 0 by resets or in standby mode. bit 6: al description 0 dack is active high (initial value) 1 dack is active low bit 5 ( dreq select bit (ds)): ds selects the dreq input detection method used. this bit is valid only in channels 0 and 1. the ds bit is initialized to 0 by resets or in standby mode. bit 5: ds description 0 dreq detected by low level (initial value) 1 dreq detected by falling edge bit 4 (transfer bus mode bit (tm)): tm selects the bus mode for dma transfers. the tm bit is initialized to 0 by resets or in standby mode. when the source of the transfer request is an on- chip peripheral module, see table 9.4, selecting on-chip peripheral module request modes with the rs bit. bit 4: tm description 0 cycle-steal mode (initial value) 1 burst mode
hitachi 179 bit 3 (transfer size bit (ts)): ts selects the transfer unit size. if the on-chip peripheral module that is the source or destination of the transfer can only be accessed in bytes, byte must be selected in this bit. the ts bit is initialized to 0 by resets or in standby mode. bit 3: ts description 0 byte (8 bits) (initial value) 1 word (16 bits) bit 2 (interrupt enable bit (ie)): ie determines whether or not to request a cpu interrupt at the end of a dma transfer. when the ie bit is set to 1, an interrupt (dei) is requested from the cpu when the te bit is set. the ie bit is initialized to 0 by resets or in standby mode. bit 2: ie description 0 interrupt request disabled (initial value) 1 interrupt requeste enabled bit 1 (transfer end flag bit (te)): te indicates that the transfer has ended. when a dma transfer ends normally and the value in the dma transfer count register (tcr) becomes 0, the te bit is set to 1. this flag is not set if the transfer ends because of an nmi interrupt or address error, or because the de bit or the dme bit of the dma operation register (dmaor) was cleared. to clear the te bit, read 1 from it and then write 0. when this flag is set, setting the de bit to 1 does not enable a dma transfer. the te bit is initialized to 0 by resets or in standby mode. bit 1: te description 0 dma has not ended or was aborted (initial value) to clear te, the cpu must read te after it has been set to 1, then write a 0 in this bit 1 dma has ended normally
180 hitachi bit 0 (dma enable bit (de)): de enables or disables dma transfers. in the auto-request mode, the transfer starts when this bit or the dme bit of the dmaor is set to 1. the te bit and the nmif and ae bits of the dmaor must be all cleared to 0. in external request mode or on-chip peripheral module request mode, the transfer begins when the dma transfer request is received from said device or on-chip peripheral module, provided this bit and the dme bit are set to 1. as with the auto request mode, the te bit and the nmif and ae bits of the dmaor must be all cleared to 0. the transfer can be stopped by clearing this bit to 0. the de bit is initialized to 0 by resets or in standby mode. bit 0: de description 0 dma transfer disabled (initial value) 1 dma transfer enabled 9.2.5 dma operation register (dmaor) the dma operation register (dmaor) is a 16-bit read/write register that controls the dma transfer mode. it also indicates the dma transfer status. it is initialized to h'0000 by a reset or the standby mode. bit: 15 14 13 12 11 10 9 8 bit name: pr1 pr0 initial value: 0 0 0 0 0 0 0 0 r/w: r r r r r r r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: ae nmif dme initial value: 0 0 0 0 0 0 0 0 r/w: r r r r r r/(w)* r/(w)* r note: write only 0 to clear the flag. bits 15?0 (reserved): these bits always read 0. the write value should always be 0.
hitachi 181 bits 9 and 8 (priority mode bits 1 and 0 (pr1 and pr0)): pr1 and pr0 select the priority level between channels when there are transfer requests for multiple channels simultaneously. bit 9: pr1 bit 8: pr0 description 0 0 fixed priority order (ch. 0 > ch. 3 > ch. 2 > ch. 1) (initial value) 0 1 fixed priority order (ch. 1 > ch. 3 > ch. 2 > ch. 0) 1 0 round-robin mode priority order (the priority order immediately after a reset is ch. 0 > ch. 3 > ch. 2 > ch. 1) 1 1 external-pin round-robin mode priority order (the priority order immediately after a reset is ch. 3 > ch. 2 > ch. 1 > ch. 0) bits 7? (reserved): these bits always read 0. the write value should always be 0. bit 2 (address error flag bit (ae)): ae indicates that an address error occurred in the dmac. when this flag is set to 1, the channel cannot be enabled even if the de bit in the dma channel control register (chcr) and the dme bit are set to 1. to clear the ae bit, read 1 from it and then write 0. it is initialized to 0 by a reset or the standby mode. bit 2: ae description 0 no dmac address error ?initial value) to clear the ae bit, read 1 from it and then write 0. 1 address error by dmac bit 1 (nmi flag bit (nmif)): nmif indicates that an nmi interrupt occurred. when this flag is set to 1, the channel cannot be enabled even if the de bit in the chcr and the dme bit are set to 1. to clear the nmif bit, read 1 from it and then write 0. it is initialized to 0 by a reset or the standby mode. bit 1: nmif description 0 no nmi interrupt (initial value) to clear the nmif bit, read 1 from it and then write 0. 1 nmi has occurred
182 hitachi bit 0 (dma master enable bit (dme)): dme enables or disables dma transfers on all channels. a channel becomes enabled for a dma transfer when the de bit in each dma's chcr and the dme bit are set to 1. for this to be effective, however, the te bit of each chcr and the nmif and ae bits must all be 0. when the dme bit is cleared, all channel dma transfers are aborted. bit 0: dme description 0 disable dma transfers on all channels (initial value) 1 enable dma transfers on all channels 9.3 operation when there is a dma transfer request, the dmac starts the transfer according to the predetermined channel priority order; when the transfer end conditions are satisfied, it ends the transfer. transfers can be requested in three modes: auto-request, external request, and on-chip module request. transfer can be in either the single address mode or the dual address mode. the bus mode can be either burst or cycle steal 9.3.1 dma transfer flow after the dma source address registers (sar), dma destination address registers (dar), dma transfer count registers (tcr), dma channel control registers (chcr), and dma operation register (dmaor) are set, the dmac transfers data according to the following procedure: 1. checks to see if transfer is enabled (de = 1, dme = 1, te = 0, nmif = 0, ae = 0) 2. when a transfer request comes and transfer is enabled, the dmac transfers 1 transfer unit of data (for an auto-request, the transfer begins automatically when the de bit and dme bit are set to 1. the tcr value will be decremented by 1). the actual transfer flows vary by address mode and bus mode. 3. when the specified number of transfer have been completed (when tcr reaches 0), the transfer ends normally. if the ie bit of the chcr is set to 1 at this time, a dei interrupt is sent to the cpu. 4. when an address error occurs in the dmac or an nmi interrupt is generated, the transfer is aborted. transfers are also aborted when the de bit of the chcr or the dme bit of the dmaor are changed to 0. figure 9.2 is a flowchart of this procedure.
hitachi 183 transfer ends normal end does nmif = 1, ae = 1, de = 0, and dme = 0? tcr = 0? de, dme = 1 and nmif, ae, te = 0? does nmif = 1, ae = 1, de = 0, or dme = 0? bus mode, transfer request mode, dreq detection selection system transfer request occurs?* 1 transfer aborted initial settings (sar, dar, tcr, chcr, dmaor) transfer (1 transfer unit); tcr? tcr, sar and dar updated dei interrupt request (when ie = 1) no yes no yes no yes yes no yes no * 3 * 2 start notes: 1. in auto-request mode, transfer begins when nmif, ae and te are all and the de and dme bits are set to 1. 2. dreq = level detection in the burst mode (external request), or cycle steal mode. 3. dreq = edge detection in the burst mode (external request), or auto request mode in burst mode. figure 9.2 dma transfer flowchart
184 hitachi 9.3.2 dma transfer requests dma transfer requests are basically generated in either the data transfer source or destination, but they can also be generated by devices and on-chip peripheral modules that are neither the source nor the destination. transfers can be requested in three modes: auto-request, external request, and on-chip module request. the request mode is selected in the rs3?s0 bits of the dma channel control registers 0? (chcr0?hcr3). auto-request mode: when there is no transfer request signal from an external source, as in a memory-to-memory transfer or a transfer between memory and an on-chip peripheral module unable to request a transfer, the auto-request mode allows the dmac to automatically generate a transfer request signal internally. when the de bits of chcr0?hcr3 and the dme bit of the dmaor are set to 1, the transfer begins (so long as the te bits of chcr0?hcr3 and the nmif and ae bits of dmaor are all 0). external request mode: in this mode a transfer is performed at the request signal ( dreq ) of an external device. choose one of the modes shown in table 9.3 according to the application system. when this mode is selected, if the dma transfer is enabled (de = 1, dme = 1, te = 0, nmif = 0, ae = 0), a transfer is performed upon a request at the dreq input. choose to detect dreq by either the falling edge or low level of the signal input with the ds bit of chcr0?hcr3 (ds = 0 is level detection, ds = 1 is edge detection). the source of the transfer request does not have to be the data transfer source or destination. table 9.3 selecting external request modes with the rs bits rs3 rs2 rs1 rs0 address mode source destination 0000 dual address mode any* any* 0010 single address mode external memory or memory-mapped external device external device with dack 0011 single address mode external device with dack external memory or memory-mapped external device note: external memory, memory-mapped external device, on-chip memory, on-chip peripheral module (excluding dmac) on-chip module request: in this mode a transfer is performed at the transfer request signal (interrupt request signal) of an on-chip module. the transfer request signals include the receive data full interrupt (rxi) of the serial communication interface (sci), the transmit data empty interrupt (txi) of the sci, the input capture a/compare match a interrupt request (imia) of the 16-bit integrated-pulse timer (itu), (table 9.4). when this mode is selected, if the dma transfer is enabled (de = 1, dme = 1, te = 0, nmif = 0, ae = 0), a transfer is performed upon the input of a transfer request signal. the source of the transfer request does not have to be the data transfer
hitachi 185 source or destination. when rxi is set as the transfer request, however, the transfer source must be the sci? receive data register (rdr). likewise, when txi is set as the transfer request, the transfer source must be the sci's transmit data register (tdr). table 9.4 selecting on-chip peripheral module request modes with the rs bit rs3 rs2 rs1 rs0 dma transfer request source dma transfer request signal source desti- nation bus mode 0 1 0 0 sci0 receiver rxi0 (sci0 receive data full interrupt transfer request) rdr0 any* cycle steal 0 1 0 1 sci0 trans- mitter txi0 (sci0 transmit data empty interrupt transfer request) any tdr0 cycle steal 0 1 1 0 sci1 receiver rxi1 (sci1 receive data full interrupt transfer request) rdr1 any* cycle steal 0 1 1 1 sci1 trans- mitter txi1 (sci1 transmit data empty interrupt transfer request) any* tdr1 cycle steal 1 0 0 0 itu0 imia0 (itu0 input capture a/ compare-match a) any* any* burst/cycle steal 1 0 0 1 itu1 imia1 (itu1 input capture a/ compare-match a) any* any* burst/cycle steal 1 0 1 0 itu2 imia2 (itu2 input capture a/ compare-match a) any* any* burst/cycle steal 1 0 1 1 itu3 imia3 (itu3 input capture a/ compare-match a) any* any* burst/cycle steal sci0, sci1: serial communications interface channels 0 and 1 itu0?tu3: channels 0? of the 16-bit integrated-timer pulse unit. rdr0, rdr1: receive data registers 0, 1 of sci tdr0, tdr1: transmit data registers 0, 1 of sci note: external memory, memory-mapped external device, on-chip memory, on-chip peripheral module (excluding dmac) when outputting transfer requests from on-chip peripheral modules, the appropriate interrupt enable bits must be set to output the interrupt signals. note that transfer request signals from on- chip peripheral modules (interrupt request signals) are sent not just to the dmac but to the cpu as well. when an on-chip peripheral module is specified as the transfer request source, set the priority level values in the interrupt priority level registers (iprc?pre) of the interrupt controller (intc) at or below the levels set in the i3?0 bits of the cpu? status register (sr) so that the cpu does not acknowledge the interrupt request signal.
186 hitachi the dma transfer request signals of table 9.4 are automatically withdrawn when the corresponding dma transfer is performed. if the cycle steal mode is being employed, the dma transfer request (interrupt request) will be cleared at the first transfer; if the burst mode is being used, it will be cleared at the last transfer. 9.3.3 channel priority when the dmac receives simultaneous transfer requests on two or more channels, it selects a channel according to a predetermined priority order. the three modes (fixed mode, round-robin mode, and external-pin round-robin mode) are selected by the priority bits pr1 and pr0 in the dma operation register. fixed mode: in these modes, the priority levels among the channels remain fixed. when pr1 and pr0 bits are set 00, the priority order, high to low, is ch. 0 > ch. 3 > ch. 2 > ch. 1. when pr1 and pr0 bits are set 01, the priority order, high to low, is ch. 1 > ch. 3 > ch. 2 > ch. 0. round-robin mode: each time one word or byte is transferred on one channel, the priority order is rotated. the channel on which the transfer was just finished rotates to the bottom of the priority order. when necessary, the priority order of channels other than the one that just finished the transfer can also be shifted to keep the relationship between the channels from changing (figure 9.3). the priority order immediately after a reset is channel 0 > channel 3 > channel 2 > channel 1.
hitachi 187 ch0 > ch3 > ch2 > ch1 ch3 > ch2 > ch1 > ch0 ch0 > ch3 > ch2 > ch1 ch2 > ch1 > ch0 > ch3 ch0 > ch3 > ch2 > ch1 ch1 > ch0 > ch3 > ch2 ch2 > ch1 > ch0 > ch3 ch0 > ch3 > ch2 > ch1 ch0 > ch3 > ch2 > ch1 (1) when channel 0 transfers initial priority order priority order after transfer (2) when channel 3 transfers initial priority order priority order after transfer (3) when channel 2 transfers initial priority order priority order after transfer post-transfer priority order when there is an immediate transfer request to channel 3 only (4) when channel 1 transfers initial priority order priority order after transfer channel 3 becomes bottom priority. the priority of channel 0, which was higher than channel 3, is also shifted. channel 0 becomes bottom priority channel 2 becomes bottom priority. the priority of channels 0and 3, which were higher than channel 2, are also shifted. if immediately thereafter there is a request to transfer channel 3 only, channel 3 becomes bottom priority and the priority of channels 0 and 1, which were higher than channel 3, are also shifted. priority order does not change figure 9.3 round-robin mode figure 9.4 shows how the priority order changes when channel 0 and channel 1 transfers are requested simultaneously and a channel 3 transfer is requested during the channel 0 transfer. the dmac operates as follows:
188 hitachi 1. transfer requests are generated simultaneously to channels 1 and 0. 2. channel 0 has a higher priority, so the channel 0 transfer begins first (channel 1 waits for transfer). 3. a channel 3 transfer request occurs during the channel 0 transfer (channels 1 and 3 are both waiting) 4. when the channel 0 transfer ends, channel 0 becomes lowest priority. 5. at this point, channel 3 has a higher priority than channel 1, so the channel 3 transfer begins (channel 1 waits for transfer). 6. when the channel 3 transfer ends, channel 3 becomes lowest priority. 7. the channel 1 transfer begins. 8. when the channel 1 transfer ends, channels 1 and 2 shift downward in priority so that channel 1 becomes the lowest priority. 1 1, 3 1 none (1) channels 0 and 1 (3) channel 3 (2) channel 0 transfer starts priority order changes 0 > 3 > 2 > 1 3 > 2 > 1 > 0 2 > 1 > 0 > 3 0 > 3 > 2 > 1 transfer request waiting channel(s) dmac operation channel priority (4) channel 0 transfer ends priority order changes priority order changes (5) channel 3 transfer starts (6) channel 3 transfer ends (7) channel 1 transfer starts (8) channel 1 transfer ends figure 9.4 changes in channel priority in round-robin mode
hitachi 189 external-pin round-robin mode: external-pin round-robin mode switches the priority levels of channel 0 and channel 1, which are the channels that can receive transfer requests from external pins dreq0 and dreq1 . the priority levels are changed after each (byte or word) transfer on channel 0 or channel 1 is completed. the channel which just finished the transfer rotates to the bottom of the priority order. the priority levels of channels 2 and 3 do not change. the initial priority order after a reset is channel 3 > channel 2 > channel 1 > channel 0. figure 9.5 shows how the priority order changes when channel 0 and channel 1 transfers are requested simultaneously and a channel 0 transfer is requested again after both channels finish their transfers. the dmac operates as follows: 1. transfer requests are generated simultaneously to channels 1 and 0. 2. channel 1 has a higher priority, so the channel 1 transfer begins first (channel 0 waits for transfer). 3. when the channel 1 transfer ends, channel 1 becomes lowest priority. 4. the channel 0 transfer begins. 5. when the channel 0 transfer ends, channel 0 becomes lowest priority. 6. a channel 0 transfer request occurs again. 7. the channel 0 transfer begins. 8. when the channel 0 transfer ends, the priority order does not change, because channel 0 is already the lowest priority.
190 hitachi 0 none none (1) channels 0 and 1 (6) channel 0 (2) channel 1 transfer starts (3) channel 1 transfer ends (5) channel 0 transfer ends (7) channel 0 transfer starts (4) channel 0 transfer starts (8) channel 0 transfer ends priority order changes 3 > 2 > 1 > 0 3 > 2 > 0 > 1 3 > 2 > 1 > 0 3 > 2 > 1 > 0 transfer request waiting channel(s) dmac operation channel priority priority order changes priority order does not change waiting for transfer request figure 9.5 example of changes in priority in external-pin round-robin mode
hitachi 191 9.3.4 dma transfer types the dmac supports the transfers shown in table 9.5. it can operate in the single address mode or dual address mode, which are defined by how many bus cycles the dmac takes to access the transfer source and transfer destination. the actual transfer operation timing varies with the bus mode. the dmac has two bus modes: cycle-steal mode and burst mode. table 9.5 supported dma transfers destination source external device with dack external memory memory- mapped external device on-chip memory on-chip peripheral module external device with dack not available single single not available not available external memory single dual dual dual dual memory-mapped external device single dual dual dual dual on-chip memory not available dual dual dual dual on-chip peripheral module not available dual dual dual dual single: single address mode dual: dual address mode
192 hitachi address modes: single address mode in the single address mode, both the transfer source and destination are external; one (selectable) is accessed by a dack signal while the other is accessed by an address. in this mode, the dmac performs the dma transfer in 1 bus cycle by simultaneously outputting a transfer request acknowledge dack signal to one external device to access it while outputting an address to the other end of the transfer. figure 9.6 shows an example of a transfer between an external memory and an external device with dack in which the external device outputs data to the data bus while that data is written in external memory in the same bus cycle. dmac dack dreq external memory external device with dack sh microcomputer external address bus : data flow external data bus read ** write (1) (2) note: the read/write direction is decided by the rs3-rs0 bits of the chcrn registers. if rs3- rs0=0010, the direction is shown as case 1 (circled number above); if rs3-rs0=0010, the direction is shown as case 2. also, dack output (when writing) indicates case 2. figure 9.6 data flow in single address mode two types of transfers are possible in the single address mode: 1) transfers between external devices with dack and memory-mapped external devices, and 2) transfers between external devices with dack and external memory. the only transfer requests for either of these is the external request ( dreq ). figure 9.7 shows the dma transfer timing for the single address mode.
hitachi 193 the dack output when a transfer occurs from an external device with dack to a memory- mapped external device is the write waveform. the dack output when a transfer occurs from a memory-mapped external device to an external device with dack is the read waveform. the setting of the acknowledge mode (am) bits in the channel control registers (chcr0, chcr1) have no effect. ck a21?0 csn d15?0 dack wrh wrl address output to external memory space data that is output from the external device with dack dack signal to external devices with dack (active low) wr signal to external memory space (a) external device with dack to external memory space ck a21?0 csn d15?0 rd address output to external memory space data that is output from external memory space rd signal to external memory space dack signal to external device with dack (active low) dack (b) external memory space to external device with dack figure 9.7 example of dma transfer timing in the single address mode
194 hitachi dual address mode in the dual address mode, both the transfer source and destination are accessed (selectable) by an address. the source and destination can be located externally or internally. the source is accessed in the read cycle and the destination in the write cycle, so the transfer is performed in two separate bus cycles. the transfer data is temporarily stored in the dmac. figure 9.8 shows an example of a transfer between two external memories in which data is read from one memory in the read cycle and written to the other memory in the following write cycle. dmac external memory external memory superh microcomputer 2 1 external data bus : data flow 1: read cycle 2: write cycle figure 9.8 data flow in dual address mode in the dual address mode transfers, external memory, memory-mapped external devices, on- chip memory and on-chip peripheral modules can be mixed without restriction. specifically, this enables the following transfer types: 1. external memory and external memory transfer 2. external memory and memory-mapped external devices transfer 3. memory-mapped external devices and memory-mapped external devices transfer 4. external memory and on-chip memory transfer 5. external memory and on-chip peripheral modules (excluding the dmac) transfer 6. memory-mapped external devices and on-chip memory transfer 7. memory-mapped external devices and on-chip peripheral modules (excluding the dmac) transfer 8. on-chip memory and on-chip memory transfer 9. on-chip memory and on-chip peripheral modules (excluding the dmac) transfer 10. on-chip peripheral modules (excluding the dmac) and on-chip peripheral modules (excluding the dmac) transfer
hitachi 195 transfer requests can be auto requests, external requests, or on-chip peripheral module requests. when the transfer request source is either the sci or a/d converter, however, either the data destination or source must be the sci or a/d converter (figure 9.4), in dual address mode, dack is output in read or write cycles to onchip memory or onchip peripheral modules. the chcr controls the cycle of dack output. figure 9.9 shows the dma transfer timing in the dual address mode. ck a21?0 cs n d15?0 dack wrh wrl rd source address destination address figure 9.9 dma transfer timing in the dual address mode (external memory space to external memory space transfer with dack output in the read cycle) bus modes: there are two bus modes: cycle steal and burst. select the mode in the tm bits of chcr0?hcr3. cycle-steal mode in the cycle steal mode, the bus right is given to another bus master after a one-transfer-unit (word or byte) dma transfer. when another transfer request occurs, the bus rights are obtained from the other bus master and a transfer is performed for one transfer unit. when that transfer ends, the bus right is passed to the other bus master. this is repeated until the transfer end conditions are satisfied. the cycle steal mode can be used with all categories of transfer destination, transfer source and transfer request. figure 9.10 shows an example of dma transfer timing in the cycle steal mode. transfer conditions shown in the figure are: ? dual address mode ? dreq level detection
196 hitachi cpu cpu cpu dmac dmac cpu dmac dmac cpu dreq bus cycle bus right returned to cpu read write read write figure 9.10 transfer example in the cycle-steal mode (dual address mode, dreq level detection) burst mode once the bus right is obtained, the transfer is performed continuously until the transfer end condition is satisfied. in the external request mode with low level detection of the dreq pin, however, when the dreq pin is driven high, the bus passes to the other bus master after the bus cycle of the dmac that currently has an acknowledged request ends, even if the transfer end conditions have not been satisfied. the burst mode cannot be used when the serial communications interface (sci) is the transfer request source. figure 9.11 shows an example of dma transfer timing in the burst mode. the transfer conditions shown in the figure are: ? single address mode ? dreq level detection cpu cpu cpu dmac dmac dmac dmac dmac dreq bus cycle dmac cpu figure 9.11 transfer example in the burst mode (single address mode, dreq level detection) relationship between request modes and bus modes by dma transfer category: table 9.6 shows the relationship between request modes and bus modes by dma transfer category.
hitachi 197 table 9.6 relationship of request modes and bus modes by dma transfer category addres s mode transfer category request mode bus mode transfer size (bits) usable channels single external device with dack and external memory external b/c 8/16 0,1 external device with dack and memory-mapped external device external b/c 8/16 0, 1 dual external memory and external memory everything* 1 b/c 8/16 0?* 5 external memory and memory- mapped external device everything* 1 b/c 8/16 0?* 5 memory-mapped external device and memory-mapped external device everything* 1 b/c 8/16 0?* 5 external memory and on-chip memory everything* 1 b/c 8/16 0?* 5 external memory and on-chip peripheral module everything* 2 b/c* 3 8/16* 4 0?* 5 memory-mapped external device and on-chip memory everything* 1 b/c 8/16 0?* 5 memory-mapped external device and on-chip peripheral module everything* 2 b/c* 3 8/16* 4 0?* 5 on-chip memory and on-chip memory everything* 1 b/c 8/16 0?* 5 on-chip memory and on-chip peripheral module everything* 2 b/c* 3 8/16* 4 0?* 5 on-chip peripheral module and on- chip?eripheral module everything* 2 b/c* 3 8/16* 4 0?* 5 b: burst, c: cycle steal notes: 1. external requests, auto requests and on-chip peripheral module requests are all available. for on-chip peripheral module requests, however, sci cannot be specified as the transfer request source. 2. external requests, auto requests and on-chip peripheral module requests are all available. when the sci is also the transfer request source, however, the transfer destination or transfer source must be the sci respectively. 3. if the transfer request source is the sci, cycle steal only. 4. the access size permitted when the transfer destination or source is an on-chip peripheral module register. 5. if the transfer request is an external request, channels 0 and 1 only. bus mode and channel priority order: when a given channel (1) is transferring in burst mode and there is a transfer request to a channel (2) with a higher priority, the transfer of the channel
198 hitachi with higher priority (2) will begin immediately. when channel 2 is also operating in the burst mode, the channel 1 transfer will continue when the channel 2 transfer has completely finished. when channel 2 is in the cycle steal mode, channel 1 will begin operating again after channel 2 completes the transfer of one transfer unit, but the bus will then switch between the two in the order channel 1, channel 2, channel 1, channel 2. since channel 1 is in burst mode, it will not give the bus to the cpu. this example is illustrated in figure 9.12. cpu bus status dmac ch1 dmac ch1 dmac ch2 dmac ch1 dmac ch2 dmac ch1 dmac ch1 cpu ch2 ch1 ch2 dmac ch1 and ch2 cycle steal mode dmac ch1 burst mode cpu cpu dmac ch1 burst mode figure 9.12 bus handling when multiple channels are operating 9.3.5 number of bus cycle states and dreq pin sample timing number of states in bus cycle: the number of states in the bus cycle when the dmac is the bus master is controlled by the bus state controller just as it is when the cpu is the bus master. the bus cycle in the dual address mode is controlled by wait state control register 1 (wcr1) while the single address mode bus cycle is controlled by wait state control register 2 (wcr2). for details, see section 8.9, wait state control. dreq pin sampling timing: normally, when dreq input is detected immediately prior to the rise edge of the clock pulse (ck) in external request mode, a dmac bus cycle will be generated and the dma transfer performed two states later at the earliest. the sampling timing after dreq input detection differs by bus mode, address mode and method of dreq input detection. ? dreq pin sampling timing in the cycle steal mode in the cycle steal mode, the sampling timing is the same regardless of whether the dreq is detected by edge or level. when edge is being detected, however, once sampled it will not be sampled again until the next edge detection. once dreq input is detected, the next sampling is not performed until the first state, among those dmac bus cycles thereby produced, in which a dack signal is output (including the detection state itself). the next sampling occurs immediately prior to the rise edge of the clock pulse(ck) of the third state after the bus cycle previous to the bus cycle in which the dack signal is output.
hitachi 199 figure 9.13 to 9.22 show the sampling timing of the pin dreq in the cycle steal mode for each bus cycle. when no dreq input is detected at the sampling after the aforementioned dreq detection, the next sampling occurs in the next stage in which a dack signal is output. if no dreq input is detected at this time, sampling occurs at every state thereafter. ck dreq dack bus cycle cpu cpu cpu dmac cpu cpu cpu cpu figure 9.13 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (single address mode, bus cycle = 1 state) ck dreq dack bus cycle cpu cpu cpu dmac (r) dmac (w) cpu cpu cpu dmac (r): dmac read cycle dmac (w): dmac write cycle note: illustrates the case when dack is output during the dmac read cycle. figure 9.14 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (dual address mode, bus cycle = 1 state)
200 hitachi ck dreq dack bus cycle cpu cpu cpu dmac cpu cpu cpu cpu figure 9.15 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (single address mode, bus cycle = 2 states) ck dreq dack bus cycle cpu cpu cpu dmac (r) dmac (w) cpu cpu cpu dmac (r): dmac read cycle dmac (w): dmac write cycle note: illustrates the case when dack is output during the dmac write cycle. figure 9.16 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (dual address mode, bus cycle = 2 states)
hitachi 201 ck dreq dack bus cycle t2 tw t1 dmac t2 tw t1 cpu cpu cpu dmac cpu cpu note: when dreq is negated at the third state of the dmac cycle, the next dma transfer will be executed because the sampling is done at the second state of the dmac cycle. figure 9.17 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (single address mode, bus cycle = 2 states + 1 wait state) dmac (r): dmac read cycle dmac (w): dmac write cycle ck dreq dack bus cycle t2 tw t1 cpu cpu dmac (r) cpu cpu t2 tw t1 cpu dmac (w) figure 9.18 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (dual address mode, bus cycle = 2 states + 1 wait state)
202 hitachi ck dreq dack bus cycle tc tr tp tc cpu cpu cpu dmac cpu cpu tc tr tp tc dmac note: when dreq is negated at the fourth state of the dmac cycle, the next dma transfer will be executed because the sampling is done at the second state of the dmac cycle. figure 9.19 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (single address mode, bus cycle = dram bus cycle (long pitch normal mode)) ck dreq dack bus cycle tc tr tp tc cpu dmac(r) dmac (r) tc tr tp tc cpu cpu dmac (w) cpu dmac (w) cpu dmac (r): dmac read cycle dmac (w): dmac write cycle note: when dreq is negated at the fourth state of the dmac cycle, the next dma transfer will be executed because the sampling is done at the second state of the dmac cycle. figure 9.20 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (dual address mode, bus cycle = dram bus cycle (long pitch normal mode))
hitachi 203 ck dreq dack bus cycle t3 t2 t1 t4 cpu cpu cpu dmac cpu cpu t3 t2 t1 t4 dmac note: when dreq is negated at the fourth state of the dmac cycle, the next dma transfer will be executed because the sampling is done at the second state of the dmac cycle. figure 9.21 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (single address mode, bus cycle = address/data multiplex i/o bus cycle) ck dreq dack bus cycle t3 t2 t1 t4 cpu dmac(r) dmac (r) t3 t2 t1 t4 cpu cpu dmac (w) cpu dmac (w) cpu dmac (r): dmac read cycle dmac (w): dmac write cycle note: when dreq is negated at the fourth state of the dmac cycle, the next dma transfer will be executed because the sampling is done at the second state of the dmac cycle. figure 9.22 dreq sampling timing in cycle steal mode (output with dreq level detection and dack active low) (dual address mode, bus cycle = address/data multiplex i/o bus cycle)
204 hitachi ? dreq pin sampling timing in the burst mode in the burst mode, the sampling timing differs depending on whether dreq is detected by edge or level. when dreq input is being detected by edge, once the falling edge of the dreq signal is detected, the dma transfer continues until the transfer end conditions are satisfied, regardless of the status of the dreq pin. no sampling happens during this time. after the transfer ends, sampling occurs every state until the te bit of the chcr is cleared. when dreq input is being detected by level, once the dreq input is detected, next sampling is performed at the end of every cpu or dmac bus cycle in the single address mode. in the dual address mode, the next sampling is performed at the start of every dmac read cycle. in both the single address mode and dual address mode, if no dreq input is detected at this time, sampling thereafter occurs at every state. figures 9.23 and 9.24 show the dreq pin sampling timing in burst mode when dreq input is detected by low level. ck dreq dack bus cycle cpu cpu dmac dmac cpu cpu dmac note: single address dreq level detection, dack active low, 1 bus cycle = 2 states. figure 9.23 dreq pin sampling timing in burst mode
hitachi 205 ck dreq dack bus cycle cpu cpu dmac(r) dmac(w) dmac(r) cpu dmac(w) note: dual address dreq level detection, dack active low, dack output in read cycle, 1 bus cycle = 2 states. figure 9.24 dreq pin sampling timing in burst mode 9.3.6 dma transfer ending conditions the dma transfer ending conditions vary for individual channels ending and all channels ending together. individual channel ending conditions: there are two ending conditions. a transfer ends when the value of the channel's dma transfer count register (tcr) is 0, or when the de bit of the channel's chcr is cleared to 0. when tcr is 0: when the tcr value becomes 0 and the corresponding channel? dma transfer ends, the transfer end flag bit (te) is set in the chcr. if the ie (interrupt enable) bit has been set, a dmac interrupt (dei) is requested to the cpu. when de of chcr is 0: software can halt a dma transfer by clearing the de bit in the channel? chcr. the te bit is not set when this happens. conditions for ending all channels simultaneously: transfers on all channels end when 1) the nmif (nmi flag) bit or ae (address error flag) bit is set to 1 in the dmaor, or 2) when the dme bit in the dmaor is cleared to 0.
206 hitachi transfers ending when the nmif or ae bit is set to 1 in dmaor: when an nmi interrupt or dmac address error occurs, the nmif or ae bit is set to 1 in the dmaor and all channels stop their transfers. the sar, dar, tcr are all updated by the transfer immediately preceding the halt. the te bit is not set. to resume the transfers after nmi interrupt exception processing or address error exception processing, clear the appropriate flag bit to 0. when a channel? de bit is then set to 1, the transfer on that channel will restart. to avoid restarting a transfer on a particular channel, keep its de bit cleared to 0. in the dual address mode, the dma transfer will be halted after the completion of the write cycle that follows the initial read cycle in which the address error occurs. sar, dar and tcr are updated by the final transfer. transfers ending when dme is cleared to 0 in dmaor: clearing the dme bit to 0 in the dmaor forcibly aborts the transfers on all channels at the end of the current cycle. the te bit is not set. 9.4 examples of use 9.4.1 dma transfer between on-chip ram and a memory-mapped external device in the following example, data is transferred from an on-chip ram to a memory-mapped external device with an input capture a/compare match a interrupt (imia0) from channel 0 of the 16-bit integrated-timer pulse unit (itu) as the transfer request signal. the transfer is performed by dmac channel 3. table 9.7 shows the transfer conditions and register values. table 9.7 transfer conditions and register settings for transfer between on-chip ram and memory-mapped external device transfer conditions register setting transfer source: on-chip ram sar3 h'ffffe00 transfer destination: memory-mapped external device dar3 destination address number of transfers: 8 tcr3 h'0008 transfer destination address: fixed chcr3 h'1805 transfer source address: incremented transfer request source (transfer request signal): itu channel 0 (imia0) bus mode: cycle steal transfer unit: byte dei interrupt request generated at end of transfer (channel 3 enabled for transfer) channel priority order: fixed (0 > 3 > 2 > 1) (all channels transfer enabled) dmaor h'0001
hitachi 207 9.4.2 example of dma transfer between on-chip sci and external memory in this example, receive data of on-chip serial communications interface (sci) channel 0 is transferred to external memory using dmac channel 3. table 9.8 shows the transfer conditions and register settings. table 9.8 transfer conditions and register settings for transfer between on-chip sci and external memory transfer conditions register setting transfer source: rdr0 of on-chip sci0 sar3 h'ffffec5 transfer destination: external memory dar3 destination address number of transfers: 64 tcr3 h'0040 transfer destination address: incremented chcr3 h'4405 transfer source address: fixed transfer request source (transfer request signal): sci0 (rxi0) bus mode: cycle steal transfer unit: byte dei interrupt request generated at end of transfer (channel 3 enabled for transfer channel priority order: fixed (0 > 3 > 2 > 1) (all channels transfer?nabled) dmaor h'0001
208 hitachi 9.5 cautions 1. all registers other than the dma operations register (dmaor) and dma channel control registers 0? (chcr0?hcr3) should be accessed in word or long word units. 2. before rewriting the rs0?s3 bits of chcr0?hcr3, first clear the de bit to 0 (when rewriting chcr with a byte access, be sure to set the de bit to 0 in advance). 3. even when the nmi interrupt is input when the dmac is not operating, the nmif bit of the dmaor will be set. 4. interrupt during dmac transfer a. when an nmi interrupt is input, the dmac stops operation and returns the bus right to the cpu. the cpu then executes the interrupt processing. b. when an interrupt other than an nmi occurs. when the dmac is in burst mode. the dmac does not return the bus right to the cpu in burst mode. therefore, even when an interrupt is requested in dmac operation, the cpu cannot get the bus right, causing the interrupt processing not to be executed. when the dmac completes transfer and the cpu gets the bus right, the cpu executes the interrupt processing if the interrupt requested during dmac transfer is not cleared.* * clear conditions for an interrupt request. ? when an interrupt is requested from an on-chip peripheral module, the interrupt factor flag is cleared. ? when an interrupt is requested by irq (edge detection), the cpu begins the irq interrupt processing of the request source. ? when an interrupt is requested by irq (level detection), the irq interrupt request signal returned to high level. when the dmac is in cycle-steal mode. the dmac returns the bus right to the cpu every when the dmac completes a transfer unit in cycle-steal mode. therefore, the cpu executes the requested interrupt processing when getting the bus right. 5. the cpu and dmac leaves the bus right released and the operation of the lsi is stopped when the following conditions are satisfied. the warp bit (warp) of the bus control register (bcr) of the bus controller (bsc)is set. the dmac is in cycle-steal transfer mode. the cpu accesses (reads/writes) the on-chip i/o space. countermeasure set the warp bit of bcr to 0 and set it to normal mode.
hitachi 209 6. notes on use of the sleep command a. operation contents when the bus cycle of dmac is entered immediately after executing the sleep command, there are cases when the dma transfer is carried out correctly. b. countermeasure stop the operation (for exemple, clearing of the dma enable bit (de) of the dma channel control register(chcrn)) before entering sleep. when using dmac during sleep, operate dmac after releasing sleep through interruption. in cases when the cpu does not carry out any other processing but is waiting for dmac to end its transfer during dmac operation, do not use the sleep command, but use the transfer end flag bit (te) of the channel dma control register and the polling software loop. phenomenon: if the bus cycle of dmac is entered immediately after executing the sleep command, the bus cycle of dmac may conflict with that of cpu. cpu address bus cpu cpu dmac cpu dmac cpu this is in itself a dmac cycle but involves cpu operation. fetch cycle of sleep command accordingly, the bus cycle of dmac which has conflicted with that of cpu may malfunction. 7. sampling of dreq if dreq is set to level detection in the dma cycle steal mode, sampling of dreq may take place before dack is output. note that some system configurations involve unnecessary dma transfers. operation as shown in figure 9.16, sampling of dreq is carried out immediately before the leading edge of the third-state clock (ck) after completion of the bus cycle preceding the dma bus cycle where dack is output. if dack is output after the third state of the dma bus cycle, sampling of dreq must be carried out before dack is output.
210 hitachi number of states of dmac bus cycle : bus cycle of dmac sampling point 1 2 3 4 figure 9.16 sampling points of dreq especially as shown in figure 9.17, if the bus cycle of dma is a full access to dram or if refresh demand is generated, sampling of dreq takes place before dack is output as mentioned above. this phenomenon is found when one of the following transfers is made with dreq set to the level detection in the dma cycle steal mode, in a system which employs dram (refresh enabled). sampling point when refresh operation is entered sampling point of dreq for dack output position differs with presence/absence of the refresh operation. refresh t1 t2 tr tp tc ck dack sampling point bus cycle of dram (full access) figure 9.17 example of dreq sampling before output of dack transfer from a device having dack to memory in the single address mode (not restricted to dram) transfer from dram to a device having dack in the single address mode output at dack write in the dual address mode output at dack read in the dual address mode and dma transfer using dram as a source countermeasure to prevent unnecessary dma transfers, configure the system where dreq is used for edge detection and the edge corresponding to the next transfer request occurs after the dack output.
hitachi 211 8. when the following operations are performed in the order shown when the pin to which dreq input is assigned is designated as a general input pin by the pin function controller (pfc) and inputs a low-level signal, the dreq falling edge is detected, and a dma transfer request accepted, immediately after the setting in (b) is performed: (a) a channel control register (chcrn) setting is made so that an interrupt is detected at the falling edge of dreq . (b) the function of the pin to which dreq input is assigned is switched from general input to dreq input by a pin function controller (pfc) setting. therefore, when switching the pin function from general input pin to dreq input, the pin function controller (pfc) setting should be changed to dreq input while the pin to which dreq input is assigned is high.
hitachi 213 section 10 16-bit integrated-timer pulse unit (itu) 10.1 overview the superh microcomputer has an on-chip 16-bit integrated-timer pulse unit (itu) with five channels of 16-bit timers. 10.1.1 features itu features are listed below: can process a maximum of twelve different pulse outputs and ten different pulse inputs. has ten general registers (gr), two per channel, that can be set to function independently as output compare or input capture. selection of eight counter input clock sources for all channels ? internal clock: f , f /2, f /4, f /8, ? external clock: tclka, tclkb, tclkc, tclkd all channels can be set for the following operating modes: ? compare match waveform output: 0 output/1 output/selectable toggle output (0 output/1 output for channel 2). ? input capture function: selectable rising edge, falling edge, or both rising and falling edges. ? counter clearing function: counters can be cleared by a compare match or input capture. ? synchronizing mode: two or more timer counters (tcnt) can be written to simultaneously. two or more timer counters can be simultaneously cleared by a compare match or input capture. counter synchronization functions enable synchronized input/output. ? pwm mode: pwm output can be provided with any duty cycle. when combined with the counter synchronizing function, enables up to five-phase pwm output. channel 2 can be set to the phase counting mode: two-phase encoder output can be counted automatically. channels 3 and 4 can be set in the following modes: ? reset-synchronized pwm mode: by combining channels 3 and 4, 3-phase pwm output is possible with positive and negative waveforms . ? complementary pwm mode: by combining channels 3 and 4, 3-phase pwm output is possible with non-overlapping positive and negative waveforms. buffer operation: input capture registers can be double-buffered. output compare registers can be updated automatically. high-speed access via internal 16-bit bus: the tcnt, gr, and buffer register (br) 16-bit registers can be accessed at high speed via a 16-bit bus.
214 hitachi fifteen interrupt sources: ten compare match/input capture interrupts (2 sources per channel) and five overflow interrupts are vectored independently for a total of 15 sources. can activate dmac: the compare match/input capture interrupts of channels 0? can start the dmac (one for each of four channels). output trigger can be generated for the programmable timing pattern controller (tpc): the compare match/input capture signals of channel 0? can be used as output triggers for the tpc. table 10.1 summarizes the itu functions.
hitachi 215 table 10.1 itu functions item channel 0 channel 1 channel 2 channel 3 channel 4 counter clocks internal: f , f /2, f /4, f /8 external: independently selectable from tclka, tclkb, tclkc, and tclkd general registers (output compare/ input capture dual registers) gra0, grb0 gra1, grb1 gra2, grb2 gra3, grb3 gra4, grb4 buffer registers no no no bra3, brb3 bra4, brb4 input/output pins tioca0, tiocb0 tioca1, tiocb1 tioca2, tiocb2 tioca3, tiocb3 tioca4, tiocb4 output pins no no no no tocxa4, tocxb4 counter clear func- tion (compare mat- ch or input capture) gra0/grb0 gra1/grb1 gra2/grb2 gra3/grb3 gra4/grb4 compare 0 yes yes yes yes yes match 1 yes yes yes yes yes output toggle output yes yes no yes yes input capture function yes yes yes yes yes synchronization yes yes yes yes yes pwm mode yes yes yes yes yes reset-synchronized pwm mode no no no yes yes complementary pwm mode no no no yes yes phase counting mode no no yes no no buffer operation no no no yes yes dmac activation gra0 com- pare match or input capture gra1 com- pare match or input capture gra2 com- pare match or input capture gra3 com- pare match or input capture no interrupt sources (three) compare match/input capture a0 compare match/input capture b0 overflow compare match/input capture a1 compare match/input capture b1 overflow compare match/input capture a2 compare match/input capture b2 overflow compare match/input capture a3 compare match/input capture b3 overflow compare match/input capture a4 compare match/input capture b4 overflow
216 hitachi 10.1.2 block diagram itu block diagram (complete): figure 10.1 is the block diagram of the itu. tocr tstr tsnc tmdr tfcr 16-bit timer channel 0 16-bit timer channel 1 16-bit timer channel 2 16-bit timer channel 3 16-bit timer channel 4 module data bus bus interface internal data bus clock selection counter control and pulse i/o control unit tclka?clkd f , f/ 2, f/ 4, f/ 8 tocxa4, tocxb4 tioca0etioca4 tiocb0etiocb4 imia0eimia4 imib0eimib4 ovi0eovi4 control logic tocr: timer output control register (8 bits) tstr: timer start regsiter (8 bits) tsnc: timer synchronization register (8 bits) tmdr: timer mode register (8 bits) tfcr: timer function control register (8 bits) figure 10.1 itu block diagram
hitachi 217 block diagram of channels 0 and 1: itu channels 0 and 1 have the same function. figure 10.2 is a block diagram of channels 0 and 1. tclka tclkd f , f /2, f /4, f /8 clock selection comparator control logic tcntn gran grbn tcrn tiorn tiern tsrn module data bus tiocan tiocbn imian imibn ovin tcntn: timer counter n (16 bits) gran, grbn: general registers an, bn (input capture/output compare dual use) (16 bits 2) tcrn: timer control register n (8 bits) tiorn: timer i/o control register n (8 bits) tiern: timer interrupt enable register n (8 bits) tsrn: timer status register n (8 bits) (n = 0 or 1) figure 10.2 channels 0 and 1 block diagram (one channel shown)
218 hitachi block diagram of channel 2: figure 10.3 is a block diagram of channel 2. channel 2 is 0 output/1 output only. tclka tclkd f , f /2, f /4, f /8 clock selection comparator control logic module data bus tioca2 tiocb2 imia2 imib2 ovi2 tcnt2 gra2 grb2 tcr2 tior2 tier2 tsr2 tcnt2: timer counter 2 (16 bits) gra2, grb2: general registers a2, b2 (input capture/output compare dual use) (16 bits 2) tcr2: timer control register 2 (8 bits) tior2: timer i/o control register 2 (8 bits) tier2: timer interrupt enable register 2 (8 bits) tsr2: timer status register 2 (8 bits) figure 10.3 channel 2 block diagram
hitachi 219 block diagrams of channels 3 and 4: figure 10.4 is a block diagram of channel 3; figure 10.5 is a block diagram of channel 4. tclka tclkd f , f /2, f /4, f /8 clock selection comparator control logic module data bus tioca3 tiocb3 imia3 imib3 ovi3 tcnt3 bra3 gra3 tcr3 tior3 tier3 tsr3 brb3 grb3 tcnt3: timer counter 3 (16 bits) gra3, grb3: general registers a3, b3 (input capture/output compare dual use) (16 bits 2) bra3, brb3: buffer registers a3, b3 (input capture/output compare dual use) (16 bits 2) tcr3: timer control register 3 (8 bits) tior3: timer i/o control register 3 (8 bits) tier3: timer interrupt enable register 3 (8 bits) tsr3: timer status register 3 (8 bits) figure 10.4 channels 3 block diagram
220 hitachi tclka tclkd f , f /2, f /4, f /8 clock selection comparator control logic module data bus tioca4 tiocb4 imia4 imib4 ovi4 tocxa4 tocxb4 gcnt4 bra4 gra4 tcr4 tior4 tier4 tsr4 brb4 grb4 tcnt4: timer counter 4 (16 bits) gra4, grb4: general registers a4, b4 (input capture/output compare dual use) (16 bits 2) bra4, brb4: buffer registers a4, b4 (input capture/output compare dual use) (16 bits 2) tcr4: timer control register 4 (8 bits) tior4: timer i/o control register 4 (8 bits) tier4: timer interrupt enable register 4 (8 bits) tsr4: timer status register 4 (8 bits) figure 10.5 channel 4 block diagram
hitachi 221 10.1.3 input/output pins table 10.2 summarizes the itu pins. external pin functions should be set with the pin function controller to match to the itu setting. see section 15, pin function controller, for details. itu pins need to be set using the pin function controller (pfc) after the lsi is set to the itu mode. table 10.2 pin configuration channel name pin name i/o function shared clock input a tclka i external clock a input pin (a-phase input pin in phase counting mode) clock input b tclkb i external clock b input pin (b-phase input pin in phase counting mode) clock input c tclkc i external clock c input pin clock input d tclkd i external clock d input pin 0 input capture/out- put compare a0 tioca0 i/o gra0 output compare/gra0 input capture/pwm output pin (in pwm mode) input capture/out- put compare b0 tiocb0 i/o grb0 output compare/grb0 input capture 1 input capture/out- put compare a1 tioca1 i/o gra1 output compare/gra1 input capture/pwm output pin (in pwm mode) input capture/out- put compare b1 tiocb1 i/o grb1 output compare/grb1 input capture 2 input capture/out- put compare a2 tioca2 i/o gra2 output compare/gra2 input capture/pwm output pin (in pwm mode) input capture/out- put compare b2 tiocb2 i/o grb2 output compare/grb2 input capture 3 input capture/out- put compare a3 tioca3 i/o gra3 output compare/gra3 input capture/pwm output pin (in pwm mode, complementary pwm mode, or reset-synchronized pwm mode) input capture/out- put compare b3 tiocb3 i/o grb3 output compare/grb3 input capture/pwm output pin (in complementary pwm mode or reset- synchronized pwm mode) 4 input capture/out- put compare a4 tioca4 i/o gra4 output compare/gra4 input capture/pwm output pin (in pwm mode, complementary pwm mode or reset-synchronized pwm mode) input capture/out- put compare b4 tiocb4 i/o grb4 output compare/grb4 input capture/pwm output pin (in complementary pwm mode or reset- synchronized pwm mode) output compare xa4 tocxa4 i/o pwm output pin (in complementary pwm mode or reset-synchronized pwm mode) output compare xb4 tocxb4 i/o pwm output pin (in complementary pwm mode or reset-synchronized pwm mode)
222 hitachi 10.1.4 register configuration table 10.3 summarizes the itu register configuration. table 10.3 register configuration channel name abbrevi- ation r/w initial value address* 1 access size shared timer start register tstr r/w h'e0/h'60 h'5ffff00 8 timer synchro register tsnc r/w h'e0/h'60 h'5ffff01 8 timer mode register tmdr r/w h'80/h'00 h'5ffff02 8 timer function control register tfcr r/w h'c0/h'40 h'5ffff03 8 timer output control register tocr r/w h'ff/h'7f h'5ffff31 8 0 timer control register 0 tcr0 r/w h'80/h'00 h'5ffff04 8 timer i/o control register 0 tior0 r/w h'88/h'08 h'5ffff05 8 timer interrupt enable register 0 tier0 r/w h'f8/h'78 h'5ffff06 8 timer status register 0 tsr0 r/(w)* 2 h'f8/h'78 h'5ffff07 8 timer counter 0 tcnt0 r/w h'00 h'5ffff08 8, 16, 32 h'5ffff09 8, 16, 32 general register a0 gra0 r/w h'ff h'5ffff0a 8, 16, 32 h'5ffff0b 8, 16, 32 general register b0 grb0 r/w h'ff h'5ffff0c 8, 16 h'5ffff0d 8, 16 1 timer control register 1 tcr1 r/w h'80/h'00 h'5ffff0e 8 timer i/o control register 1 tior1 r/w h'88/h'08 h'5ffff0f 8 timer interrupt enable register 1 tier1 r/w h'f8/h'78 h'5ffff10 8 timer status register 1 tsr1 r/(w)* 2 h'f8/h'78 h'5ffff11 8 timer counter 1 tcnt1 r/w h'00 h'5ffff12 8, 16 h'5ffff13 8, 16 general register a1 gra1 r/w h'ff h'5ffff14 8, 16, 32 h'5ffff15 8, 16, 32 general register b1 grb1 r/w h'ff h'5ffff16 8, 16, 32 h'5ffff17 8, 16, 32
hitachi 223 table 10.3 register configuration (cont) channel name abbrevi- ation r/w initial value address* 1 access size 2 timer control register 2 tcr2 r/w h'80/h'00 h'5ffff18 8 timer i/o control register 2 tior2 r/w h'88/h'08 h'5ffff19 8 timer interrupt enable register 2 tier2 r/w h'f8/h'78 h'5ffff1a 8 timer status register 2 tsr2 r/(w)* 2 h'f8/h'78 h'5ffff1b 8 timer counter 2 tcnt2 r/w h'00 h'5ffff1c 8, 16, 32 h'5ffff1d 8, 16, 32 general register a2 gra2 r/w h'ff h'5ffff1e 8, 16, 32 h'5ffff1f 8, 16, 32 general register b2 grb2 r/w h'ff h'5ffff20 8, 16 h'5ffff21 8, 16 3 timer control register 3 tcr3 r/w h'80/h'00 h'5ffff22 8 timer i/o control register 3 tior3 r/w h'88/h'08 h'5ffff23 8 timer interrupt enable register 3 tier3 r/w h'f8/h'78 h'5ffff24 8 timer status register 3 tsr3 r/(w)* 2 h'f8/h'78 h'5ffff25 8 timer counter 3 tcnt3 r/w h'00 h'5ffff26 8, 16 h'5ffff27 8, 16 general register a3 gra3 r/w h'ff h'5ffff28 8, 16, 32 h'5ffff29 8, 16, 32 general register b3 grb3 r/w h'ff h'5ffff2a 8, 16, 32 h'5ffff2b 8, 16, 32 buffer register a3 bra3 r/w h'ff h'5ffff2c 8, 16, 32 h'5ffff2d 8, 16, 32 buffer register b3 brb3 r/w h'ff h'5ffff2e 8, 16, 32 h'5ffff2f 8, 16, 32 4 timer control register 4 tcr4 r/w h'80/h'00 h'5ffff32 8 timer i/o control register 4 tior4 r/w h'88/h'08 h'5ffff33 8 timer interrupt enable register 4 tier4 r/w h'f8/h'78 h'5ffff34 8 timer status register 4 tsr4 r/(w)* 2 h'f8/h'78 h'5ffff35 8
224 hitachi table 10.3 register configuration (cont) channel name abbrevi- ation r/w initial value address* 1 access size 4 (cont) timer counter 4 tcnt4h r/w h'00 h'5ffff36 8, 16 h'5ffff37 8, 16 general register a4 gra4h r/w h'ff h'5ffff38 8, 16, 32 h'5ffff39 8, 16, 32 general register b4 grb4h r/w h'ff h'5ffff3a 8, 16, 32 h'5ffff3b 8, 16, 32 buffer register a4 bra4h r/w h'ff h'5ffff3c 8, 16, 32 h'5ffff3d 8, 16, 32 buffer register b4 brb4h r/w h'ff h'5ffff3e 8, 16, 32 h'5ffff3f 8, 16, 32 notes: 1. only the values of bits a27?24 and a8?0 are valid; bits a23?9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 2. write 0 to clear flags. 10.2 itu register descriptions 10.2.1 timer start register (tstr) the timer start register (tstr) is an eight-bit read/write register that starts and stops the timer counters (tcnt) of channels 0?. tstr is initialized to h'e0 or h'60 upon reset or standby mode. bit: 7 6 5 4 3 2 1 0 bit name: str4 str3 str2 str1 str0 initial value: * 1 1 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w note: undefined bits 7? (reserved): cannot be modified. bit 7 is read as undefined. bits 6 and 5 are always read as 1. the write value to bit 7 should be 0 or 1, and the write value to bits 6 and 5 should always be 1.
hitachi 225 bit 4 (count start 4 (str4)): str4 starts and stops tcnt4. bit 4: str4 description 0 tcnt4 is halted (initial value) 1 tcnt4 is counting bit 3 (count start 3 (str3)): str3 starts and stops tcnt3. bit 3: str3 description 0 tcnt3 is halted (initial value) 1 tcnt3 is counting bit 2 (count start 2 (str2)): str2 starts and stops tcnt2. bit 2: str2 description 0 tcnt2 is halted (initial value) 1 tcnt2 is counting bit 1 (count start 1 (str1)): str1 starts and stops tcnt1. bit 1: str1 description 0 tcnt1 is halted (initial value) 1 tcnt1 is counting bit 0 (count start 0 (str0)): str0 starts and stops tcnt0. bit 0: str0 description 0 tcnt0 is halted (initial value) 1 tcnt0 is counting
226 hitachi 10.2.2 timer synchro register (tsnc) the timer synchro register (tsnc) is an eight-bit read/write register that selects timer synchronizing modes for channels 0?. channels for which 1 is set to the corresponding bit will be synchronized. tsnc is initialized to h'e0 or h'60 upon reset or standby mode. bit: 7 6 5 4 3 2 1 0 bit name: sync4 sync3 sync2 sync1 sync0 initial value: * 1 1 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w note: undefined bits 7? (reserved): bit 7 is read as undefined. bits 6 and 5 are always read as 1. the write value to bit 7 should be 0 or 1, and the write value to bits 6 and 5 should always be 1. bit 4 (timer synchro 4 (sync4)): sync4 selects the synchronizing mode for channel 4. bit 4: sync4 description 0 the timer counter for channel 4 (tcnt4) operates independently (preset/clear of tcnt4 is independent of other channels) (initial value) 1 channel 4 operates synchronously. synchronized preset/clear of tnct4 enabled. bit 3 (timer synchro 3 (sync3)): sync3 selects the synchronizing mode for channel 3. bit 3: sync3 description 0 the timer counter for channel 3 (tcnt3) operates independently (preset/clear of tcnt3 is independent of other channels) (initial value) 1 channel 3 operates synchronously. synchronized preset/clear of tnct3 enabled. bit 2 (timer synchro 2 (sync2)): sync2 selects the synchronizing mode for channel 2. bit 2: sync2 description 0 the timer counter for channel 2 (tcnt2) operates independently (preset/clear of tcnt2 is independent of other channels) (initial value) 1 channel 2 operates synchronously. synchronized preset/clear of tnct2 enabled.
hitachi 227 bit 1 (timer synchro 1 (sync1)): sync1 selects the synchronizing mode for channel 1. bit 1: sync1 description 0 the timer counter for channel 1 (tcnt1) operates independently (preset/clear of tcnt1 is independent of other channels) (initial value) 1 channel 1 operates synchronously. synchronized preset/clear of tnct1 enabled. bit 0 (timer synchro 0 (sync0)): sync0 selects the synchronizing mode for channel 0. bit 0: sync0 description 0 the timer counter for channel 0 (tcnt0) operates independently (preset/clear of tcnt0 is independent of other channels) (initial value) 1 channel 0 operates synchronously. synchronized preset/clear of tnct0 enabled. 10.2.3 timer mode register (tmdr) the timer mode register (tmdr) is an eight-bit read/write register that selects the pwm mode for channels 0?, sets the phase counting mode for channel 2, and sets the conditions for the overflow flag (ovf). tmdr is initialized to h'80 or h'00 by a reset or the standby mode. bit: 7 6 5 4 3 2 1 0 bit name: mdf fdir pwm4 pwm3 pwm2 pwm1 pwm0 initial value: * 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w note: undefined bit 7 (reserved): bit 7 is read as undefined. the write value should be 0 or 1. bit 6 (phase counting mode (mdf)): mdf selects the phase counting mode for channel 2. bit 6: mdf description 0 channel 2 operates normally (initial value) 1 channel 2 operates in phase counting mode
228 hitachi when the mdf is set to 1 to select the phase counting mode, the timer counter (tcnt2) becomes an up/down counter and the tclka and tclkb pins become count clock input pins. tcnt2 counts on both the rising and falling edges of tclka and tclkb, with the increment/decrement chosen as follows: count direction decrement increment tclka pin rising high falling low rising high falling low tclkb pin l rising high falling high falling low rising in the phase counting mode, selections for external clock edge made in the ckeg1 and ckeg0 bits of the timer control register 2 (tcr2) and the selection for counter clock made in the tpsc2 ?psc0 bits are ignored. the phase counting mode described above takes priority. settings for counter clear conditions in the cclr1 and cclr0 bits of tcr2 and settings for timer i/o control register 2 (tior2), timer interrupt enable register (tier2) and timer status register 2 (tsr2) compare match/input capture functions and interrupts, however, are valid even in the phase counting mode. bit 5 (flag direction (fdir)): fdir selects the setting condition for the overflow flag (ovf) in timer status register 2 (tsr2). this bit is valid no matter which mode channel 2 is operating in. bit 5: fdir description 0 ovf of tsr2 is set to 1 when tcnt2 overflows or underflows (initial value) 1 ovf of tsr2 is set to 1 when tcnt2 overflows bit 4 (pwm mode 4 (pwm4)): pwm4 selects the pwm mode for channel 4. when the pwm4 bit is set to 1 and the pwm mode entered, the tioca4 pin becomes a pwm output pin. 1 is output on a compare match of general register a4 (gra4); 0 is output on a compare match of general register b4 (grb4). when the complementary pwm mode or reset- synchronized pwm mode are set by the cmd1 and cmd0 bits of the timer function control register (tfcr), the setting of this bit is ignored in favor of the settings of cmd1 and cmd0. bit 4: pwm4 description 0 channel 4 operates normally (initial value) 1 channel 4 operates in pwm mode
hitachi 229 bit 3 (pwm mode 3 (pwm3)): pwm3 selects the pwm mode for channel 3. when the pwm3 bit is set to 1 and the pwm mode entered, the tioca3 pin becomes a pwm output pin. 1 is output on a compare match of general register a3 (gra3); 0 is output on a compare match of general register b3 (grb3). when the complementary pwm mode or reset- synchronized pwm mode are set by the cmd1 and cmd0 bits of the timer function control register (tfcr), the setting of this bit is ignored in favor of the settings of cmd1 and cmd0. bit 3: pwm3 description 0 channel 3 operates normally (initial value) 1 channel 3 operates in pwm mode bit 2 (pwm mode 2 (pwm2)): pwm2 selects the pwm mode for channel 2. when the pwm2 bit is set to 1 and the pwm mode entered, the tioca2 pin becomes a pwm output pin. 1 is output on a compare match of general register a2 (gra2); 0 is output on a compare match of general register b2 (grb2). bit 2: pwm2 description 0 channel 2 operates normally (initial value) 1 channel 2 operates in pwm mode bit 1 (pwm mode 1 (pwm1)): pwm1 selects the pwm mode for channel 1. when the pwm1 bit is set to 1 and the pwm mode entered, the tioca1 pin becomes a pwm output pin. 1 is output on a compare match of general register a1 (gra1); 0 is output on a compare match of general register b1 (grb1). bit 1: pwm1 description 0 channel 1 operates normally (initial value) 1 channel 1 operates in pwm mode bit 0 (pwm mode 0 (pwm0)): pwm0 selects the pwm mode for channel 0. when the pwm0 bit is set to 1 and the pwm mode entered, the tioca0 pin becomes a pwm output pin. 1 is output on a compare match of general register a0 (gra0); 0 is output on a compare match of general register b0 (grb0). bit 0: pwm0 description 0 channel 0 operates normally (initial value) 1 channel 0 operates in pwm mode
230 hitachi 10.2.4 timer function control register (tfcr) the timer function control register (tfcr) is an 8-bit read/write register that selects complementary pwm/reset-synchronized pwm for channels 3 and 4 and sets the buffer operation. tfcr is initialized on a reset or standby mode to h'c0 or h'40. bit: 7 6 5 4 3 2 1 0 bit name: cmd1 cmd0 bfb4 bfa4 bfb3 bfa3 initial value: * 1 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w note: undefined bits 7 and 6 (reserved): bit 7 is read as undefined. bit 6 is always read as 1. the write value to bit 7 should be 0 or 1. the write value to bit 6 should always be 1. bits 5 and 4 (combination mode 1 and 0 (cmd1 and cmd0)): cmd1 and cmd0 select the complementary pwm mode or reset-synchronized mode for channels 3 and 4. set the complementary pwm/reset-synchronized pwm mode while the timer counter (tcnt) being used is off. when these bits are used to set the complementary pwm/reset-synchronized pwm mode, they take priority over the pwm4 and pwm3 bits of the tmdr. while the complementary pwm/reset-synchronized pwm mode settings and the sync4 and sync3 bit settings of the timer synchro register (tsnc) are valid simultaneously, when the complementary pwm mode is set, channels 3 and 4 should not be set to operate simultaneously (sync 4 and sync 3 bits of tsnc should not both be set to 1). bit 5: cmd1 bit 4: cmd0 description 0 0 channels 3 and 4 operate normally (initial value) 1 channels 3 and 4 operate normally 1 0 channels 3 and 4 operate together in complementary pwm mode 1 channels 3 and 4 operate together in reset-synchronized pwm mode bit 3 (buffer mode b4 (bfb4)): bfb4 selects the buffer mode for grb4 and brb4 in channel 4. bit 3: bfb4 description 0 grb4 operates normally in channel 4 (initial value) 1 grb4 and brb4 operate in buffer mode in channel 4
hitachi 231 bit 2 (buffer mode a4 (bfa4)): bfa4 selects the buffer mode for gra4 and bra4 in channel 4. bit 2: bfa4 description 0 gra4 operates normally in channel 4 (initial value) 1 gra4 and bra4 operate in buffer mode in channel 4 bit 1 (buffer mode b3 (bfb3)): bfb3 selects the buffer mode for grb3 and brb3 in channel 3. bit 1: bfb3 description 0 grb3 operates normally in channel 3 (initial value) 1 grb3 and brb3 operate in buffer mode in channel 3 bit 0 (buffer mode a3 (bfa3)): bfa3 selects the buffer mode for gra3 and bra3 in channel 3. bit 0: bfa3 description 0 gra3 operates normally in channel 3 (initial value) 1 gra3 and bra3 operate in buffer mode in channel 3 10.2.5 timer output control register (tocr) the timer output control register (tocr) is an eight-bit read/write register that inverts the output level of the complementary pwm mode/reset-synchronized pwm mode. setting bits ols3 and ols4 is valid in only the complementary pwm mode and reset-synchronized pwm mode. in other output situations, these bits are ignored. the tocr is initialized to h'ff or h'7f by a reset or in the standby mode. bit: 7 6 5 4 3 2 1 0 bit name: ols4 ols3 initial value: * 1 1 1 1 1 1 1 r/w: r/w r/w note: undefined bits 7? (reserved): bit 7 is read as undefined. bits 6? are always read as 1. the write value to bit 7 should be 0 or 1. the write value to bits 6? should always be 1.
232 hitachi bit 1 (output level select 4 (ols4)): ols4 selects the output level of the complementary pwm mode or reset-synchronized pwm mode. bit 1: ols4 description 0 tioca3, tioca4, and tiocb4 are inverted and output 1 tioca3, tioca4, and tiocb4 are output directly (initial value) bit 0 (output level select 3 (ols3)): ols3 selects the output level of the complementary pwm mode or reset-synchronized pwm mode. bit 0: ols3 description 0 tiocb3, tocxa4, and tocxb4 are inverted and output 1 tiocb3, tocxa4, and tocxb4 are output directly (initial value) 10.2.6 timer counters (tcnt) the itu has five 16-bit timer counters (tcnt), one for each channel (table 10.4). each tcnt is a 16-bit read/write counter that counts by input from a clock source. the clock source is selected by timer prescalar bits 2? (tpsc2?psc0) in the timer control register (tcr). tcnt0 and tcnt 1 are strictly upcounters. up/down counting occurs for tcnt2 when the phase counting mode is selected, or for tcnt3 and tcnt 4 when complementary pwm mode is selected. in other modes, they are upcounters. the tcnt can be cleared to h'0000 by compare match with the corresponding general register a or b (gra, grb) or input capture to gra or grb (counter clear function). when the tcnt overflows (changes from h'ffff?'0000), the overflow flag (ovf) in the timer status register (tsr) is set to 1. the ovf of the corresponding channel tsr is also set to 1 when the tcnt underflows (changes from h'0000?'ffff). the tcnt is connected to the cpu by a 16-bit bus, so it can be written or read by either word access or byte access. the tcnt is initialized to h'0000 by a reset or in standby mode.
hitachi 233 table 10.4 timer counters (tcnt) channel abbreviation function 0 tcnt0 increment counter 1 tcnt1 2 tcnt2 phase counting mode: increment/decrement all others: increment 3 tcnt3 complementary pwm mode: increment/decrement 4 tcnt4 all others: increment bit: 15 14 13 12 11 10 9 8 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 10.2.7 general registers a and b (gra and grb) each of the five itu channels has two 16-bit general registers (gr) for a total of ten registers (table 10.5). each gr is a 16-bit read/write register that can function as either an output compare register or an input capture register. the function is selected by settings in the timer i/o control register (tior). when a general register (gra/grb) is used as an output compare register, its value is constantly compared with the timer counter (tcnt) value. when the two values match (compare match), the imfa/imfb bit is set to 1 in the timer status register (tsr). if compare match output is selected in the tior, a specified value is output at the output compare pin. when a general register is used as an input capture register, an external input capture signal is detected and the tcnt value is stored. the imfa/imfb bit of the corresponding tsr is set to 1 at the same time. the valid edge or edges of the input capture signal are selected in the tior. the tior setting is ignored when set for the pwm mode, complementary pwm mode or reset- synchronized pwm mode.
234 hitachi general registers are connected to the cpu by a 16-bit bus, so general registers can be written or read by either word access or byte access. general registers are initialized to the output compare register (no pin output) by a reset or in standby mode. the initial value is h'ffff. table 10.5 general registers a and b (gra and grb) channel abbreviation function 0 gra0, grb0 output compare/input capture dual register 1 gra1, grb1 2 gra2, grb2 3 gra3, grb3 output compare/input capture dual register. can also be set for 4 gra4, grb4 buffer operation in combination with the buffer registers (bra, brb) bit: 15 14 13 12 11 10 9 8 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 10.2.8 buffer registers a and b (bra, brb) each buffer register is a 16-bit read/write register that is used in the buffer mode. the itu has four buffer registers, two each for channels 3 and 4 (table 10.6). buffer operation can be set independently by the timer function control register (tfcr) bits bfb4, bfa4, bfb3, and bfb3 bits. the buffer registers are paired with the general registers and their function changes automatically to match the function of its corresponding general register. the buffer registers are connected to the cpu by a 16-bit bus, so they can be written or read by either word or byte access. buffer registers are initialized to h'ffff by a reset or in standby mode.
hitachi 235 table 10.6 buffer registers a and b (bra, brb) channel abbreviation function 3 bra3, brb3 when used for buffer operation: 4 bra4, brb4 when the corresponding gra and grb are output compare registers, the buffer registers function as output compare buffer registers that can automatically transfer the bra and brb values to gra and grb upon a compare match. when the corresponding gra and grb are input capture registers, the buffer registers function as input capture buffer registers that can automatically transfer the values stored until an input capture in the gra and grb to the bra and brb. bit: 15 14 13 12 11 10 9 8 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 10.2.9 timer control register (tcr) the tcr is an 8-bit read/write register that selects the timer counter clock, the edges of the external clock source, and the counter clear source. each itu channel has one tcr. tcr is initialized h'80 or h'00 by a reset or the standby mode (table 10.7). table 10.7 timer control register (tcr) channel abbre- viation function 0 tcr0 the tcr controls the tcnts. the tcrs have the same functions on all 1 tcr1 channels. when channel 2 is set for phase counting mode, setting the 2 tcr2 ckeg1, ckeg2 and tpsc2?psc0 bits will have no effect. 3 tcr3 4 tcr4
236 hitachi bit: 7 6 5 4 3 2 1 0 bit name: cclr1 cclr0 ckeg1 ckeg0 tpsc2 tpsc1 tpsc0 initial value: * 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w note: undefined bit 7 (reserved): bit 7 is read as undefined. the write value should be 0 or 1. bits 6 and 5 (counter clear 1 and 0 (cclr1 and cclr0)): cclr1 and cclr0 select the counter clear source. bit 6: cclr1 bit 5: cclr0 description 0 0 tcnt is not cleared (initial value) 1 tcnt is cleared by general register a (gra) compare match or input capture* 1 1 0 tcnt is cleared by general register b (grb) compare match or input capture* 1 1 synchronizing clear: tcnt is cleared in synchronization with clear of other timer counters operating in sync.* 2 notes: 1. when gr is functioning as an output compare register, tcnt is cleared upon a compare match. when functioning as an input capture register, tcnt is cleared upon input capture. 2. the timer synchro register (tsnc) set the synchronization. bits 4 and 3 (external clock edge 1/0 (ckeg1 and ckeg0)): ckeg1 and ckeg0 select external clock input edges. when channel 2 is set for phase counting mode, settings of the ckeg1 and ckeg0 of the tcr are ignored and the phase counting mode operation takes priority. bit 4: ckeg 1 bit 3: ckeg 0 description 0 0 count rising edges (initial value) 1 count falling edges 1 count both rising and falling edges bits 2? (timer prescalar 2? (tps2?ps0)): tps2?ps0 select the counter clock source. when tpsc2 = 0 and an internal clock source is selected, the timer counts only falling edges. when tpsc2 = 1 and an external clock is selected, the count edge is as set by ckeg1 and ckeg0. when the phase counting mode is selected for channel 2 (mdf bit in the timer mode register is 1), the settings of tpsc2?psc0 of tcr2 are ignored and the phase counting operation takes priority.
hitachi 237 bit 2: tpsc2 bit 1: tpsc1 bit 0: tpsc0 counter clock (and cycle when f = 10 mhz) 0 0 0 internal clock f (initial value) 1 internal clock f /2 1 0 internal clock f /4 1 internal clock f /8 1 0 0 external clock a (tclka) 1 external clock b (tclkb) 1 0 external clock c (tclkc) 1 external clock d (tclkd) 10.2.10 timer i/o control register (tior) the timer i/o control register (tior) is an eight-bit read/write register that selects the output compare or input capture function for the general registers gra and grb. it also selects the function of the tioca and tiocb pins. if output compare is selected, the tior also selects the output settings. if input capture is selected, the tior also select the input capture edges. tior is initialized to h'88 or h'08 on a reset or standby mode. each itu channel has one tior (table 10.8). table 10.8 timer i/o control register (tior) channel abbre- viation function 0 tior0 the tior controls the grs. some functions vary during pwm. when 1 tior1 channels 3 and 4 are set for complementary pwm mode/reset-synchronized 2 tior2 pwm mode, tior3 and tior4 settings are not valid. 3 tior3 4 tior4 bit: 7 6 5 4 3 2 1 0 bit name: iob2 iob1 iob0 ioa2 ioa1 ioa0 initial value: * 0 0 0 1 0 0 0 r/w: r/w r/w r/w r/w r/w r/w note: undefined bit 7 (reserved): bit 7 is read as undefined. the write value should be 0 or 1.
238 hitachi bits 6? (i/o control b2?0 (iob2?ob0)): iob2?ob0 selects the grb function. bit 6: iob2 bit 5: iob1 bit 4: iob0 grb function 0 0 0 grb is an compare match with pin output disabled (initial value) 1 output compare 0 output at grb compare match* 1 10 register 1 output at grb compare match* 1 1 output toggles at grb compare match (1 output for channel 2 only)* 1, * 2 1 0 0 grb is an grb captures rising edge of input 1 input capture grb captures falling edge of input 10 register grb captures both edges of input 1 notes: 1. after reset, the value output is 0 until the first compare match occurs. 2. channel 2 has no compare-match driven toggle output function. if it is set for toggle, 1 is automatically selected as the output. bit 3 (reserved): bit 3 always reads as 1. the write value should always be 1. bits 2? (i/o control a2?0 (ioa2?oa0)): ioa2?oa0 select the grb function. bit 2: ioa2 bit 1: ioa1 bit 0: ioa0 gra function 0 0 0 gra is an compare match with pin output disabled (initial value) 1 output compare 0 output at gra compare match* 1 10 register 1 output at gra compare match* 1 1 output toggles at gra compare match (1 output for channel 2 only)* 1, * 2 1 0 0 gra is an gra captures rising edge of input 1 input capture gra captures falling edge of input 10 register gra captures both edges of input 1 notes: 1. after reset, the value output is 0 until the first compare match occurs. 2. channel 2 has no compare-match driven toggle output function. if it is set for toggle, 1 is automatically selected as the output.
hitachi 239 10.2.11 timer status register (tsr) the timer status register (tsr) is an eight-bit read/write register containing flags that indicate timer counter (tcnt) overflow/underflow and general register (gra/grb) compare match or input capture. these flags are interrupt sources. if the interrupt is enabled by the corresponding bit in the timer interrupt enable register (tier), an interrupt is requested of the cpu. tsr is initialized by a reset or standby mode to h'f8 or h'78. each itu channel has one tsr (table 10.9). table 10.9 timer status register (tsr) channel abbreviation function 0 tsr0 the tsr indicates input capture, compare match and 1 tsr1 overflow status. 2 tsr2 3 tsr3 4 tsr4 bit: 7 6 5 4 3 2 1 0 bit name: ovf imfb imfa initial value: * 1 11 11 0 00 r/w: r/(w)* 2 r/(w)* 2 r/(w)* 2 notes: 1. undefined 2. write 0 to clear the flag. bits 7? (reserved): bit 7 is read as undefined. bits 6? are always read as 1. the write value to bit 7 should be 0 or 1. the write value to bits 6? should always be 1. bit 2 (overflow flag (ovf)): ovf indicates a tcnt overflow/underflow has occurred. bit 2: ovf description 0 clearing condition: read ovf when ovf = 1, then write 0 in ovf (initial value) 1 setting condition: tcnt overflowed from h'ffff?'0000 or underflowed from h'0000?'ffff. note: a tcnt underflow occurs when the tcnt up/down counter is functioning. it may occur in the following cases: (1) when channel 2 is set in the phase counting mode (mdf bit of tmdr is 1), or (2) when channel 3 and 4 are set to the complementary pwm mode (cmd1 bit of tfcr is 1 and cmd0 bit is 0).
240 hitachi bit 1 (input capture/compare match b (imfb)): imfb indicates a grb compare match or input capture. bit 1: imfb description 0 clearing condition: read imfb when imfb = 1, then write 0 in imfb (initial value) 1 setting condition: grb is functioning as an output compare register and tcnt = grb grb is functioning as an input capture register and the value of tcnt is transferred to grb by an input capture signal bit 0 (input capture/compare match a (imfa)): imfa indicates a gra compare match or input capture. bit 0: imfa description 0 read imfa when imfa = 1, then write 0 in imfa (initial value). clearing condition: dmac is activated by an imia interrupt (only channels 0?) 1 setting condition: gra is functions as an output compare register and tcnt = gra gra is functioning as an input capture register and the value of tcnt is transferred to gra by an input capture signal 10.2.12 timer interrupt enable register (tier) the timer status interrupt enable register (tier) is an eight-bit read/write register that controls enabling/disabling of overflow interrupt requests and general register compare match/input capture interrupt requests. tier is initialized by a reset or standby mode to h'f8 or h'78. each itu channel has one tier (table 10.10). table 10.10 timer interrupt enable register (tier) channel abbreviation function 0 tier0 the tier controls interrupt enable/disable. 1 tier1 2 tier2 3 tier3 4 tier4
hitachi 241 bit: 7 6 5 4 3 2 1 0 bit name: ovie imieb imiea initial value: * 1 1 1 1 0 0 0 r/w: r/w r/w r/w note: undefined bits 7? (reserved): bit 7 is read as undefined. bits 6? are always read as 1. the write value to bit 7 should be 0 or 1. the write value to bits 6? should always be 1. bit 2 (overflow interrupt enable (ovie)): when the tsr overflow flag (ovf) is set to 1, ovie enables or disables interrupt requests from the ovf. bit 2: ovie description 0 disables interrupt requests by the ovf (initial value) 1 enables interrupt requests from the ovf bit 1 (input capture/compare match interrupt enable b (imieb)): when the imfb bit of the tsr is set to 1, imieb enables or disables the interrupt requests from the imfb. bit 1: imieb description 0 disables interrupt requests by the imfb (imib) (initial value) 1 enables interrupt requests from the imfb (imib) bit 0 (input capture/compare match interrupt enable a (imiea)): when the imfa bit of the tsr is set to 1, imiea enables or disables the interrupt requests from the imfa. bit 0: imiea description 0 disables interrupt requests by the imfa (imia) (initial value) 1 enables interrupt requests from the imfa (imia) 10.3 cpu interface 10.3.1 16-bit accessible registers the timer counters (tcnt), general registers a and b (gra, grb), and buffer registers a and b (bra, brb) are 16-bit registers. the sh cpu can access these registers a word at a time using a 16-bit data bus. byte access is also possible. read and write operations performed on the tcnt in word units are shown in figures 10.6 and 10.7. byte-unit read and write operations on tcnth and tcntl are shown in figures 10.8?0.11.
242 hitachi tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.6 accessing tcnt (cpu?cnt (word)) tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.7 accessing tcnt (tcnt?pu (word)) tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.8 accessing tcnt (cpu?cnt (upper byte))
hitachi 243 tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.9 accessing tcnt (cpu?cnt (lower byte)) tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.10 accessing tcnt (tcnt?pu (upper byte)) tcnth tcntl h l bus interface h l cpu internal data bus module data bus figure 10.11 accessing tcnt (tcnt?pu (lower byte)) 10.3.2 8-bit accessible registers all registers other than the tcnt, general registers, and buffer registers are 8-bit registers. these are connected to the cpu by an 8-bit data bus. figures 10.12 and 10.13 illustrate reading and writing in byte units with the timer control register (tcr). these registers must be accessed by byte access.
244 hitachi tcr bus interface internal data bus module data bus cpu figure 10.12 tcr access (cpu?cr) tcr bus interface internal data bus module data bus cpu figure 10.13 tcr access (tcr?pu ) 10.4 description of operation 10.4.1 overview the operation modes are described below. ordinary operation: each channel has a timer counter (tcnt) and general register (gr). the tcnt is an upcounter and can also operate as a free-running counter, periodic counter or external event counter. general registers a and b (gra and grb) can be used as output compare registers or input capture registers. synchronized operation: the tcnt of a channel set for synchronized operation does a synchronized preset. when any tcnt of a channel operating in the synchronized mode is rewritten, the tcnts of other channels are simultaneously rewritten as well. the cclr1 and cclr0 bits of the timer control register of multiple channels set for synchronous operation can be set to clear the tcnts simultaneously.
hitachi 245 pwm mode: in pwm mode, a pwm waveform is output from the tioca pin. output becomes 1 upon compare match a and 0 upon compare match b. gra and grb can be set so that the pwm waveform output has a duty cycle between 0% and 100%. when set for pwm mode, the gra and grb automatically become output compare registers. reset-synchronized pwm mode: three pairs of positive and negative pwm waveforms can be obtained using channels 3 and 4 (the three phases of the pwm waveform share a transition point on one side). when set for reset-synchronized pwm mode, gra3, grb3, gra4, and grb4 automatically become output compare registers. the tioca3, tiocb3, tioca4, tocxa4, tiocb4, and tocxb4 pins also automatically become pwm output pins and tcnt3 becomes an upcounter. tcnt4 functions independently (although gra and grb are isolated from tcnt4). complementary pwm mode: three pairs of complementary positive and negative pwm waveforms whose positive and negative phases do not overlap can be obtained using channels 3 and 4. when set for complementary pwm mode, gra3, grb3, gra4, and grb4 automatically become output compare registers. the tioca3, tiocb3, tioca4, tocxa4, tiocb4, and tocxb4 pins also automatically become pwm output pins while tcnt3 and tcnt4 become upcounters. phase counting mode: in phase counting mode, the phase differential between two clocks input from the tclka and tclkb pins is detected and the tcnt2 operates as an up/downcounter. in phase counting mode, the tclka and tclkb pins become clock inputs and tcnt2 functions as an up/downcounter. buffer mode: when gr is an output compare register: the br value of each channel is transferred to the gr when a compare match occurs. when gr is an input capture register: the tcnt value is transferred to the gr when an input capture occurs and simultaneously the value previously stored in the gr is transferred to the br. complementary pwm mode: when the tcnt3 and tcnt4 change count directions, the br value is transferred to the gr. reset-synchronized pwm mode: the br value is transferred to gr upon a gra3 compare match. 10.4.2 basic functions counter operation: when a start bit (str0?tr4) in the timer start register (tstr) is set to 1, the corresponding timer counter (tcnt) starts counting. there are two counting modes: a free- running mode and a periodic mode.
246 hitachi procedure for selecting counting mode (figure 10.14): 1. set bits tpsc2?psc0 in the tcr to select the counter clock source. if an external clock source is selected, set bits ckeg1 and ckeg0 in the tcr to select the desired edges of the external clock signal. 2. to operate as a periodic counter, set cclr1 and cclr0 in the tcr to select whether to clear the tcnt at gra compare match or grb compare match. 3. set the gra or grb selected in step 2 as an output compare register using the timer i/o control register (tior). 4. write the desired cycle value in the gra or grb selected in step 1. 5. set the str bit in the tstr to 1 to start counting. counting mode selection select counter clock periodic counter select counter clear source select output compare register set period start counting start counting counting? no yes free-running counter periodic counter free-running counter (5) (5) (4) (3) (2) (1) figure 10.14 procedure for selecting the counting mode
hitachi 247 free-running count and periodic count a reset of the counters for channels 0? leaves them all in the free-running mode. when a corresponding bit in the tstr is set to 1, the corresponding timer counter operates as a free- running counter and begins to increment. when the count wraps around from h'ffff?'0000, the overflow flag (ovf) in the timer status register (tsr) is set to 1. if the ovie bit in the timer? corresponding interrupt enable register (tier) is set to 1, the cpu will be asked for an interrupt. after the tcnt overflows, counting continues from h'0000. figure 10.15 shows an example of free-running counting. periodic counter operation is obtained for a given channel? tcnt by selecting compare match as a tcnt clear source. (set the gra or grb for period setting to output compare register and select counter clear upon compare match using the cclr1 and cclr0 bits of the timer control register (tcr).) after setting, the tcnt begins incrementing as a periodic counter when the corresponding bit of tstr is set to 1. when the count matches gra or grb, the imfa/imfb bit in the tsr is set to 1 and the counter is automatically cleared to h'0000. if the imiea/imieb bit of the corresponding tier is set to 1 at this point, the cpu will be asked for an interrupt. after the compare match, tcnt continues counting from h'0000. figure 10.16 shows an example of periodic counting. h'ffff h'0000 str0?tr4 ovf tcnt value time figure 10.15 free-running counter operation
248 hitachi gr h'0000 str0?tr4 imf tcnt value time counter cleared by gr compare match figure 10.16 periodic counter operation tcnt counter timing internal clock source: bits tpsc2?psc0 in the tcr select the system clock (ck) or one of three internal clock sources ( f /2, f /4, f /8) obtained by prescaling the system clock. figure 10.17 shows the timing. external clock source: the external clock input pin (tclkaetclkd) source is selected by bits tpsc2etpsc0 in the tcr and its valid edges are selected with the ckeg1 and ckeg0 bits of the tcr. the rising edge, falling edge, or both edges can be selected. the pulse width of the external clock signal must be at least 1.5 system clocks when a single edge is selected and at least 2.5 system clocks when both edges are selected. shorter pulses will not be counted correctly. figure 10.18 shows the timing when both edges are detected. ck n e 1 n n + 1 internal clock tcnt input clock tcnt value figure 10.17 count timing for internal clock sources
hitachi 249 ck n ?1 n n + 1 external clock input pin tcnt input clock tcnt figure 10.18 count timing for external clock sources compare-match waveform output function: for itu channels 0, 1, 3, and 4, the output from the corresponding tioca and tiocb pins upon compare matches a and b can be in three modes: 0-level output, 1-level output, or toggle. toggle output cannot be selected in channel 2. procedure for selecting the waveform output mode (figure 10.19): 1. set the tior to select 0 output, 1 output, or toggle output for compare match output. the compare match output pin will output 0 until the first compare match occurs. 2. set a value in the gra or grb to select the compare match timing. 3. set the str bit in the tstr to 1 to start counting. output selection select waveform output mode select output timing start counting waveform output (1) (2) (3) figure 10.19 procedure for selecting the compare match waveform output mode
250 hitachi waveform output operation figure 10.20 illustrates 0 output/1 output. in the example, tcnt is a free-running counter, 0 is output upon compare match a and 1 is output upon compare match b. when the pin level matches the set level, the pin level does not change. figure 10.21 shows an example of toggle output. in the figure, the tcnt operates as a periodic counter cleared by grb compare match with toggle output at both compare match a and compare match b. h'ffff tiocb tcnt value time grb gra tioca does not change does not change 1 output does not change does not change 0 output figure 10.20 example of 0 output/1 output
hitachi 251 tiocb tcnt value time grb gra tioca counter cleared at grb compare match toggle output toggle output figure 10.21 example of toggle output
252 hitachi compare match output timing the compare match signal is generated in the last state in which the tcnt and the general register match (when the tcnt changes from the matching value to the next value). when a compare match signal is generated, the output value set in tior is output to the output compare pin (tioca, tiocb). accordingly, when the tcnt matches a general register, the compare match signal is not generated until the next counter clock pulse. figure 10.22 shows the output timing of the compare match signal. n n n ?1 ck tcnt input clock tcnt gr compare match signal tioca tiocb figure 10.22 compare match signal output timing
hitachi 253 input capture mode: in the input capture mode, the counter value is captured into a general register when the input edge is detected at an input capture/output compare pin (tioca, tiocb). detection can take place on the rising edge, falling edge, or both edges. pulse width and cycle can be measured by using the input capture function. procedure for selecting the input capture mode (figure 10.23) 1. set the tior to select the input capture function of the gr and select the rising edge, falling edge, or both edges as the input edge of the input capture signal. put the corresponding port into input-capture using the pin function controller before setting the tior. 2. set the str bit in the tstr to 1 to start the tcnt counting. input selection select input-capture input start counting capture figure 10.23 procedure for selecting input capture mode
254 hitachi input capture operation figure 10.24 illustrates input capture. the falling edge of tiocb and both edges of tioca are selected as input capture edges. in the example, tcnt is set to clear at the input capture of grb. counter cleared by tiocb input (falling edge) tcnt value h'0180 h'0160 h'0005 h'0000 tiocb tioca gra grb h'0005 h'0160 h'0180 time figure 10.24 input capture operation
hitachi 255 input capture timing input capture on the rising edge, falling edge, or both edges can be selected by settings in the tior. figure 10.25 shows the timing when the rising edge is selected. the pulse width of the input capture signal must be at least 1.5 system clocks for single-edge capture, and 2.5 system clocks for capture of both edges. n ck input capture input tcnt input capture signal gra/grb n figure 10.25 input capture signal timing
256 hitachi 10.4.3 synchronizing mode in the synchronizing mode, two or more timer counters can be rewritten simultaneously (synchronized preset). multiple timer counters can also be cleared simultaneously using tcr settings (synchronized clear). the synchronizing mode can increase the general registers for a single time base. all five channels can be set for synchronous operation. procedure for selecting the synchronizing mode (figure 10.26): 1. set 1 in the sync bit of the timer synchro register (tsnc) to use the channels in the synchronizing mode. 2. when a value is written in the tcnt in any of the synchronized channels, the same value is simultaneously written in the tcnt in the other channels. 3. set the counter to clear with compare match/input capture using bits cclr1 and cclr0 in the tcr. 4. set the counter clear source to synchronized clear using the cclr1 and cclr0 bits. 5. set the str bits in the tstr to 1 to start counting in the tcnt. select counter clear source channel that generated clear source? no yes select synchronizing mode set synchronizing mode synchronized preset set tcnt start counting select counter clear source start counting counter clear synchronized clear synchronizing preset synchronized clear (1) (2) (3) (5) (4) (5) figure 10.26 procedure for selecting the synchronizing mode
hitachi 257 synchronized operation: figure 10.27 shows an example of synchronized operation. channels 0, 1, and 2 are set to synchronized operation and pwm output. channel 0 is set for a counter clear upon compare match with grb0. channels 1 and 2 are set for counter clears by synchronizing clears. accordingly, their timers are sync preset, then sync cleared by a grb0 compare match, and then a three-phase pwm waveform is output from the tioca0, tioca1 and tioca2 pins. see section 10.4.4, pwm mode, for details on the pwm mode. tcnt0?cnt2 values time tioca0 synchronized clear on grb0 compare match grb0 grb1 gra0 grb2 gra1 gra2 tioca1 tioca2 figure 10.27 synchronized operation example
258 hitachi 10.4.4 pwm mode the pwm mode is controlled using both the gra and grb in pairs. the pwm waveform is output from the tioca output pin. the pwm waveform? 1 output timing is set in gra and the 0 output timing is set in grb. a pwm waveform with duty cycle between 0% and 100% can be output from the tioca pin by having either compare match gra or grb be the counter clear source for the timer counter. all five channels can be set to pwm mode. table 10.11 lists the combinations of pwm output pins and registers. note that when the gra and grb are set to the same value, the output will not change even if a compare match occurs. table 10.11 combinations of pwm output pins and registers channel output pin 1 output 0 output 0 tioca0 gra0 grb0 1 tioca1 gra1 grb1 2 tioca2 gra2 grb2 3 tioca3 gra3 grb3 4 tioca4 gra4 grb4 procedure for selecting the pwm mode (figure 10.28): 1. set bits tpsc2?psc0 in the tcr to select the counter clock source. if an external clock source is selected, set bits ckeg1 and ckeg0 in the tcr to select the desired edges of the external clock signal. 2. set cclr1 and cclr0 in the tcr to select the counter clear source. 3. set the time at which the pwm waveform should go to 1 in the gra. 4. set the time at which the pwm waveform should go to 0 in the grb. 5. set the pwm bit in tmdr to select the pwm mode. when the pwm mode is selected, regardless of the contents of tior, the gra and grb become output compare registers specifying the times at which the pwm waveform goes high and low. tioca automatically becomes a pwm output pin. tiocb becomes whatever is set in the tior's iob1 and iob0 bits. 6. set the str bit in the tstr to let the tcnt start counting.
hitachi 259 (1) (2) (3) (4) (5) (6) pwm mode select counter clock set gra set grb select pwm mode start counting pwm mode select counter clear source figure 10.28 procedure for selecting the pwm mode pwm mode operation: figure 10.29 illustrates pwm mode operations. when the pwm mode is set, the tioca pin becomes the output pin. output is 1 when the tcnt matches the gra, and 0 when the tcnt matches the grb. the tcnt can be cleared by compare match with either gra or grb. this can be used in both free-running and synchronized operation. figure 10.30 shows examples of pwm waveforms output with 0% and 100% duty cycles. a 0% duty waveform can be obtained by setting the counter clear source to grb and then setting gra to a larger value than grb. a 100% duty waveform can be obtained by setting the counter clear source to gra and then setting grb to a larger value than gra.
260 hitachi counter cleared by gra compare match tcnt value gra grb tioca time counter cleared by grb compare match tcnt value grb gra tioca time a. counter cleared by gra b. counter cleared by grb figure 10.29 pwm mode operation example 1
hitachi 261 counter cleared on compare match b tcnt value grb tioca time gra write gra write a. 0% duty gra counter cleared on compare match a tcnt value gra grb tioca time grb write grb write b. 100% duty h'0000 h'0000 figure 10.30 pwm mode operation example 2
262 hitachi 10.4.5 reset-synchronized pwm mode in the reset-synchronized pwm mode, three pairs of complementary positive and negative pwm waveforms that share a common wave turning point can be obtained using channels 3 and 4. when set for reset-synchronized pwm mode, the tioca3, tiocb3, tioca4, tocxa4, tiocb4, and tocxb4 pins automatically become pwm output pins and tcnt3 becomes an upcounter. table 10.12 shows the pwm output pins used and table 10.13 shows the settings of the registers used. table 10.12 output pins for reset-synchronized pwm mode channel output pin description 3 tioca3 pwm output 1 tiocb3 pwm output 1' (negative-phase waveform of pwm output 1) 4 tioca4 pwm output 2 tocxa4 pwm output 2' (negative-phase waveform of pwm output 2) tiocb4 pwm output 3 tocxb4 pwm output 3' (negative-phase waveform of pwm output 3) table 10.13 register settings for reset-synchronized pwm mode register description of contents tcnt3 initial setting of h'0000 tcnt4 not used (functions independently) gra3 set count cycle for tcnt3 grb3 sets the turning point for pwm waveform output by the tioca3 and tiocb3 pins gra4 sets the turning point for pwm waveform output by the tioca4 and tocxa4 pins grb4 sets the turning point for pwm waveform output by the tiocb4 and tocxb4 pins procedure for selecting the reset-synchronized pwm mode (figure 10.31): 1. clear the str3 bits in the tstr to halt tcnt3. the reset-synchronized pwm mode must be set up while tcnt3 is halted. 2. set bits tpsc2?psc0 in the tcr to select the counter clock source for channel 3. if an external clock source is selected, select the external clock edges with bits ckeg1 and ckeg0 in the tcr. 3. set bits cclr1 and cclr0 in the tcr3 to select gra3 as a counter clear source. 4. set bits cmd1 and cmd0 in tmdb to select the reset-synchronized pwm mode. tioca3 tiocb4, tocxa4, and tocxb4 automatically become pwm output pins.
hitachi 263 5. reset the tcnt3 (to h'0000). the tcnt4 need not be set. 6. the gra3 is the waveform period register. set the waveform period value in the gra3. set the transition times of the pwm output waveforms in the grb3, gra4, and grb4. set times within the compare match range of the tcnt3. x gra3 (x: setting value) 7. set the str3 bits in the tstr to 1 to let the tcnt3 start counting. (1) (2) (3) (4) (5) (6) stop counting select counter clock start counting select counter clear source reset synchronized pwm mode select reset-synchronized pwm mode set tcnt set general registers (7) reset-synchronized pwm mode figure 10.31 procedure for selecting the reset-synchronized pwm mode
264 hitachi reset-synchronized pwm mode operation: figure 10.32 shows an example of operation in the reset-synchronized pwm mode. tcnt3 operates as an upcounter that is cleared to h'0000 at compare match with gra3. tcnt4 runs independently and is isolated from gra4 and grb4. the pwm waveform outputs toggle at each compare match (grb3, gra3, and grb4 with tcnt3) and when the counter is cleared. see section 10.4.8, buffer mode, for details on simultaneously setting reset-synchronized pwm mode and buffer operation. gra3 grb3 grb4 gra4 tioca3 tiocb3 tioca4 tocxa4 tiocb4 tocxb4 counter cleared at gra3 compare match time tcnt value figure 10.32 reset-synchronized pwm mode operation example 1 10.4.6 complementary pwm mode in the complementary pwm mode, three pairs of complementary, non-overlapping, positive and negative pwm waveforms can be obtained using channels 3 and 4. in complementary pwm mode, the tioca3, tiocb3, tioca4, tocxa4, tiocb4, and tocxb4 pins automatically become pwm output pins and tcnt3 and tcnt4 become upcounters. table 10.14 shows the pwm output pins used and table 10.15 shows the settings of the registers used.
hitachi 265 table 10.14 output pins for complementary pwm mode channel output pin description 3 tioca3 pwm output 1 tiocb3 pwm output 1' (non-overlapping negative-phase waveform of pwm output 1) 4 tioca4 pwm output 2 tocxa4 pwm output 2' (non-overlapping negative-phase waveform of pwm output 2) tiocb4 pwm output 3 tocxb4 pwm output 3' (non-overlapping negative-phase waveform of pwm output 3) table 10.15 register settings for complementary pwm mode register description of contents tcnt3 initial setting of non-overlap cycle (the difference with tcnt4) tcnt4 initial setting of h'0000 gra3 set upper limit of tcnt3? grb3 sets the turning point for pwm waveform output by the tioca3 and tiocb3 pins. gra4 sets the turning point for pwm waveform output by the tioca4 and tocxa4 pins. grb4 sets the turning point for pwm waveform output by the tiocb4 and tocxb4 pins. procedure for selecting the complementary pwm mode (figure 10.33): 1. clear str3 and str4 bits in the tstr to halt the timer counters. the complementary pwm mode must be set up while tcnt3 and tcnt4 are halted. 2. set bits tpsc2?psc0 in the tcr to select the same counter clock source for channels 3 and 4. if an external clock source is selected, select the external clock edges with bits ckeg1 and ckeg0 in the tcr. do not select any counter clear source with bits cclr1 and cclr0 in the tcr. 3. set bits cmd1 and cmd0 in tmdb to select the complementary pwm mode. tioca3 tiocb4, tocxa4, and tocxb4 automatically become pwm pins. 4. reset tcnt4 (to h'0000). set the non-overlap offset in tcnt3. do not set tcnt3 and tcnt4 to the same value.
266 hitachi 5. gra3 is the waveform period register. set the upper limit of tcnt3?*. set the transition times of the pwm output waveforms in grb3, gra4, and grb4. set times within the compare match range of tcnt3 and tcnt4. t x (x: initial setting of grb3, gra4, and grb4; t: initial setting of tcnt3) note: gra3 = [cycle count/2] + [count of non-overlaps] ?2cyc=[upper limit of tcnt3] ?1 6. set the str3 and str4 bits in the tstr to 1 to let tcnt3 and tcnt4 start counting. (1) (2) (3) (4) (5) (6) set general registers start counting complementary pwm mode stop counting select counter clock set tcnt complementary pwm mode select complementary pwm mode note to re-engage the complementary pwm mode after it has been aborted, start settings from step 1. figure 10.33 procedure for selecting the complementary pwm mode complementary pwm mode operation: figure 10.34 shows an example of operation in the complementary pwm mode. tcnt3 and tcnt4 operate as up/downcounters, counting down from compare match of tcnt3 and gra3 and counting up when tcnt4 underflows. pwm waveforms are output by repeated compare matches with each of the general registers in the
hitachi 267 sequence tcnt3, tcnt4, tcnt4, tcnt3 (in this mode, tcnt3 starts out larger than tcnt4). figure 10.35 shows examples of pwm waveforms with 0% and 100% duty cycles (in one phase) in the complementary pwm mode. in this example, the pin output changes upon grb3 compare match, so duty cycles of 0% and 100% can be obtained by setting grb3 to a value larger than gra3. combining buffer operation with the above operation makes it easy to change the duty while operating. see section 10.4.8, buffer operation, for details. down-counting starts at compare match between tcnt3 and gra3 tcnt3 tcnt4 tcnt3, tcnt4 value gra3 grb3 gra4 grb4 tioca3 tiocb3 tioca4 tocxa4 tiocb4 tocxb4 up-counting starts at tcnt4 underflow time figure 10.34 complementary pwm mode operation example 1
268 hitachi tcnt3, tcnt4 value gra3 grb3 tioca3 tiocb3 time duty 0% (a) with 0% duty tioca3 tiocb3 gra3 grb3 tcnt3, tcnt4 value time duty 100% (b) with 100% duty figure 10.35 complementary pwm mode operation example 2 at the point where the up-count/down-count changes in the complementary pwm mode, tcnt3 and tcnt4 will overshoot and undershoot, respectively. when this occurs, the setting conditions for the imfa bit of channel 3 and the overflow flag (ovf) of channel 4 are different from usual. transfer conditions for the buffer also differ. the timing is as shown in figures 10.36 and 10.37.
hitachi 269 n? n n + 1 n n? tcnt3 gra3 imfa buffer transfer signal (br to gr) gr set to 1 n buffer transfer performed flag not set buffer transfer not performed figure 10.36 overshoot timing gr buffer transfer signal (br to gr) tcnt4 h' 0001 h' 0000 h' ffff h' 0000 underflow flag not set set to 1 buffer transfer performed buffer transfer not performed ovf overflow figure 10.37 undershoot timing
270 hitachi the imfa bit of channel 3 is set to 1 for increment pulses and the ovf bit of channel 4 is set to 1 for underflows only. the buffer register (br) set for the buffer operation is transferred to the gr upon compare match a3 (when incrementing) or tcnt4 underflow. gr setting in complementary mode: be aware of the following when setting the general registers in complementary pwm mode and when making changes during operation. initial values: setting h'0000 to t? (the initial setting t: tcnt3) is prohibited. after counting starts, this setting is allowed from the point when the first a3 compare match occurs. methods of changing settings: use the buffer operation. writing directly to general registers may result in incorrect waveform output. when changing settings: see figure 10.38. gra3 gr h' 0000 br gr prohibited figure 10.38 example of changing gr settings with buffer operation (1)
hitachi 271 buffer transfers when changing from increment to decrement: when the contents of the gr are within gra3 ?t + 1 and gra3, do not transfer a value outside this range. when the contents of gr are outside this range, do not a transfer a value within it. figure 10.39 illustrates a point of caution regarding changing of gr settings with a buffer operation. gra3 + 1 gra3 gra3 ?t + 1 gra3 ?t tcnt3 tcnt4 changes inhibited figure 10.39 caution for changing gr settings with buffer operation (1) buffer transfers when changing from decrement to increment: when the contents of the gr are within h'0000 to t?, do not transfer a value outside this range. when the contents of gr are outside this range, do not transfer a value within it. figure 10.40 illustrates this point of caution regarding changing of gr settings with a buffer operation tcnt4 t t ?1 h' 0000 h' ffff tcnt3 changes inhibited figure 10.40 caution for changing gr settings with buffer operation (2) when gr settings are outside the count range (h'0000?ra3): waveforms of duty cycle 0% and 100% can be output by setting gr outside the count area. be sure to make the direction of the count (increment/decrement) when writing a setting from outside the count area into the buffer register (br) the same as the count direction when writing the setting that returns to within the count area in the br.
272 hitachi gra3 gr h' 0000 output pin output pin br gr duty 0% duty 100% write on decrement write on increment figure 10.41 example of changing gr settings with buffer operation (2) the above settings are made by detecting the occurrence of a gra3 compare match or underflow of tcnt4 and then writing to br. they can also be accomplished by starting up the dmac with a gra3 compare match. 10.4.7 phase counting mode the phase counting mode detects the phase differential of two external clock inputs (tclka and tclkb) and counts tcnt2 up or down. when set in the phase counting mode, the tclka and tclkb pins automatically become external clock input pins, regardless of the settings of the tpsc2?psc0 bits of tcr2 or the ckeg1 and ckeg0 bits. tcnt2 also becomes an up/down counter. since the tcr2 cclr1/cclr0 bits, tior2, tier2, tsr2, gra2 and grb2 are all enabled, input capture and compare match functions and interrupt sources can be used. phase counting is available only in channel 2. procedure for selecting the phase counting mode: figure 10.42 shows the procedure for selecting the phase counting mode. 1. set the mdf bit of the timer mode register (tmdr) to 1 to select the phase counting mode. 2. select the flag set conditions using the fdir bit of the tmdr. 3. set the str2 bit of the timer start register (tstr) to 1 to start the count.
hitachi 273 (1) (2) (3) phase counting mode start counting phase counting mode select phase counting mode select flag setting condition figure 10.42 procedure for selecting the phase counting mode phase counting operation: figure 10.43 shows an example of phase counting mode operation. table 10.16 lists the upcounting and downcounting conditions for tcnt2. the itu counts on both rise and fall edges of tclka and tclkb. the phase differential and overlap of tclka and tclkb must be 1.5 cycles or more and the pulse width must be 2.5 cycles or more. tcnt2 value increment decrement tclkb tclka tcnt2 time figure 10.43 phase counting mode operation table 10.16 up/down counting conditions counting direction increment decrement tclkb rising high falling low rising high falling low tclka low rising high falling high falling low rising
274 hitachi tclka tclkb phase differential phase differential, overlap: 1.5 cycles minimum pulse width: 2.5 cycles minimum phase differential pulse width pulse width overlap overlap figure 10.44 phase differentials, overlap and pulse width in the phase counting mode 10.4.8 buffer mode in the buffer mode, the buffer operation functions differ depending on whether the general registers are set to output compare or input capture, the reset-synchronized pwm mode, or complementary pwm mode. the buffer mode is a function of channels 3 and 4 only. buffer operations set this way function as follows. gr is an output compare register: the value of the buffer registers of a channel is transferred to the gr when the channel experiences a compare match. this is illustrated in figure 10.45. br gr comparator tcnt compare match signal figure 10.45 compare match buffer operation gr is an input capture register: tcnt values are transferred to gr when input capture occurs and the value previously stored in gr is transferred to br. this operation is illustrated in figure 10.46.
hitachi 275 input capture signal br gr tcnt figure 10.46 input capture buffer operation complementary pwm mode: when the count direction of tcnt3 and tcnt4 change, the br value is transferred to the gr. the following timing is employed for this transfer: whenever tcnt3 and gra3 compare-match whenever tcnt4 underflows reset-synchronized pwm mode: the br value is transferred to gr upon a gra3 compare match. procedure for selecting the buffer mode (figure 10.47): 1. set the tior to select the output compare or input capture function of the gr. 2. set bits bfa3, bfb3 and bfb4 in the tfcr to select the buffer mode for the gr. 3. set the str bit in the tstr to 1 to start the tcnt counting. (1) (2) (3) select general register function buffer mode select buffer mode start counting buffer mode figure 10.47 procedure for selecting the buffer mode
276 hitachi buffer mode operation: figure 10.48 shows an example of an operation in the buffer mode with gra set as an output compare register and gra and buffer register a (bra) set for buffer operation. the tcnt operates as a periodic counter that is cleared by grb compare match. tioca and tiocb are set to toggle at compare matches a and b. since buffer mode is selected, when tioca toggles at a compare match a, the bra value is simultaneously transferred to the gra. this operation is repeated at every compare match a. the transfer timing is shown in figure 10.49. grb h' 0250 h' 0200 h' 0100 h' 0000 bra gra tiocb tioca h' 0200 h' 0100 h' 0200 h' 0250 h' 0200 h' 0200 tcnt value counter cleared by compare match b time toggle output toggle output compare match a h' 0100 figure 10.48 buffer mode operation example 1 (output compare register)
hitachi 277 ck tcnt compare match signal buffer transfer signal br gr n n + 1 n n n figure 10.49 compare match timing example for buffer operation
278 hitachi figure 10.50 shows an example of input capture operation in the buffer mode between gra and bra with gra as an input capture register. the tcnt is cleared by input capture b. the falling edge is selected as the input capture edge at tiocb. both edges are selected as input capture edges at tioca. when the tcnt value is stored in gra by input capture a, the previous gra value is transferred to the bra. the timing is shown in figure 10.51. tcnt value h' 0180 h' 0160 h' 0005 tiocb tioca gra bra grb counter cleared at input capture b time h' 0005 h' 0160 h' 0005 h' 0160 h' 0180 input capture a figure 10.50 buffer mode operation example 2 (input capture register)
hitachi 279 ck tioc pin input capture signal tcnt br gr n n + 1 n n + 1 m m nnn mmn figure 10.51 input capture timing example for buffer operation an example of buffer operation in the complementary pwm mode between grb3 and brb3 is as shown in figure 10.52. by making grb3 larger than gra3 using the buffer operation, a pwm waveform with a duty cycle of 0% is generated. the transfer from brb?rb occurs upon tcnt3 and gra compare match and tcnt4 underflow. tcnt3 and tcnt4 values h' 1fff gra3 h' 0999 h' 0000 brb3 grb3 tioca3 tiocb3 h' 1fff h' 1fff time h' 0999 h' 0999 h' 1fff h' 0999 tcnt3 tcnt4 grb3 h' 0999 h' 0999 figure 10.52 buffer operation 4 (complementary pwm mode)
280 hitachi 10.4.9 itu output timing itu outputs in channels 3 and 4 can be inverted with the tocr. output inversion timing with the tocr: output levels can be inverted by inverting the output level select bits (ols4 and ols3) of the tocr in the complementary pwm mode and reset- synchronized pwm mode. figure 10.53 illustrates the timing. t1 t3 t2 ck address tocr inversion tocr address itu output pin figure 10.53 example of inverting itu output levels by writing to tocr
hitachi 281 10.5 interrupts the itu has two interrupt sources: input capture/compare match and overflow. 10.5.1 timing of setting status flags timing for setting imfa and imfb in a compare match: the imf bits of the tsr are set to 1 by a compare match signal generated when the tcnt matches a general register. the compare match signal is generated in the last state in which the values match (when the tcnt is updated from the matching count to the next count). therefore, when the tcnt matches the gra or grb, the compare match signal is not generated until the next timer clock input. figure 10.54 shows the timing of setting the imf bits. ck tcnt input clock tcnt gr compare match signal imf imi n n n + 1 figure 10.54 timing of setting compare match flags (imfa, imfb)
282 hitachi timing of setting imfa, imfb for input capture: the imfa and imfb are set to 1 by an input capture signal. at this time, the tcnt contents are transferred to the gr. figure 10.55 shows the timing. ck input capture signal tcnt gr imf imi n n figure 10.55 timing of setting imfa and imfb for input capture timing of setting overflow flag (ovf): the ovf is set to 1 when the tcnt overflows from h'ffff?'0000 or underflows from h'0000?'ffff. figure 10.56 shows the timing.
hitachi 283 h' ffff h' 0000 ck tcnt overflow signal ovf ovi figure 10.56 timing of setting ovf 10.5.2 clear timing of status flags the status flags are cleared by a write cycle in which 1 is read on the cpu and then 0 is written to it. this timing is shown in figure 10.57. t1 t3 t2 ck address imf, ovf tsr address tsr write cycle figure 10.57 timing of status flag clearing
284 hitachi 10.5.3 interrupt sources and activating the dmac the itu has compare match/input capture a interrupts, compare match/input capture b interrupts and overflow interrupts for each channel. each of the fifteen of these three types of interrupts are allocated their own independently vectored addresses. when the interrupt? interrupt request flag is set to 1 and the interrupt enable bit is set to 1, the interrupt is requested. the channel priority order can be changed with the interrupt controller. for more information, see section 5, interrupt controller. the compare match/input capture a interrupts of channels 0? can start the dmac to transfer data. table 10.17 lists the interrupt sources. table 10.17 itu interrupt sources channel interrupt source description dmac activation priority order* 0 imia0 compare match or input capture a0 yes high imib0 compare match or input capture b0 no - ovi0 overflow 0 no 1 imia1 compare match or input capture a1 yes imib1 compare match or input capture b1 no ovi1 overflow 1 no 2 imia2 compare match or input capture a2 yes imib2 compare match or input capture b2 no ovi2 overflow 2 no 3 imia3 compare match or input capture a3 yes imib3 compare match or input capture b3 no ovi3 overflow 3 no 4 imia4 compare match or input capture a4 no imib4 compare match or input capture b4 no ovi4 overflow 4 no low note: indicates the initial status following reset. the ranking of channels can be altered using the interrupt controller.
hitachi 285 10.6 notes and precautions this section describes contention and other matters requiring special attention during itu operations. 10.6.1 contention between tcnt write and clear if a counter clear signal occurs in the t3 state of a tcnt write cycle, clearing the counter takes priority and the write is not performed. the timing is shown in figure 10.58. t1 t3 t2 ck address internal write signal counter clear signal tcnt tcnt write cycle by cpu tcnt address n h' 0000 figure 10.58 contention between tcnt write and clear
286 hitachi 10.6.2 contention between tcnt word write and increment if an increment pulse occurs in the t3 state of a tcnt word write cycle, writing takes priority and the tcnt is not incremented. the timing is shown in figure 10.59. t1 t3 t2 ck address internal write signal tcnt input clock tcnt tcnt word write cycle by cpu tcnt address n m tcnt write data figure 10.59 contention between tcnt word write and increment
hitachi 287 10.6.3 contention between tcnt byte write and increment if an increment pulse occurs in the t2 state or t3 state of a tcnt byte write cycle, counter writing takes priority and the byte data on the side that was previously written is not incremented. the tcnt byte data that was not written is also not incremented and retains its previous value. the timing is shown in figure 10.60 (which shows an increment during state t2 of a byte write cycle to tcnth). t1 t3 t2 ck address internal write signal tcnt input clock tcnth tcnth byte write cycle by cpu tcnth address n m tcnt write data x x + 1 x tcntl figure 10.60 contention between tcnt byte write and increment
288 hitachi 10.6.4 contention between gr write and compare match if a compare match occurs in the t3 state of a general register (gr) write cycle, writing takes priority and the compare match signal is inhibited. the timing is shown in figure 10.61. t1 t2 t3 gr write cycle gr address n n + 1 nm gr write data inhibited ck address internal write signal tcnt gr compare match signal figure 10.61 contention between general register write and compare match
hitachi 289 10.6.5 contention between tcnt write and overflow/underflow if an overflow occurs in the t3 state of a tcnt write cycle, writing takes priority over counter incrementing. the ovf is set to 1. the same applies to underflows. this timing is shown in figure 10.62. t1 t2 t3 tcnt write cycle tcnt address h'ffff m tcnt write data ck address internal write signal tcnt input clock overflow signal tcnt ovf figure 10.62 contention between tcnt write and overflow
290 hitachi 10.6.6 contention between general register read and input capture if an input capture signal is generated during the t3 state of a general register read cycle, the value before input capture is read. the timing is shown in figure 10.63. t1 t2 t3 gr read cycle gr address xm ck address internal read signal input capture signal gr internal data bus x figure 10.63 contention between general register read and input capture
hitachi 291 10.6.7 contention between counter clearing by input capture and counter increment if an input capture signal and counter increment signal occur simultaneously, the counter is cleared according to the input capture signal. the counter is not incremented by the increment signal. the tcnt value before the counter is cleared is transferred to the general register. the timing is shown in figure 10.64. n h'0000 ck input capture signal counter clear signal tcnt input clock tcnt gr n figure 10.64 contention between counter clearing by input capture and counter increment
292 hitachi 10.6.8 contention between general register write and input capture if an input capture signal is generated during the t3 state of a general register write cycle, the input capture transfer takes priority and the write to the gr is not performed. the timing is shown in figure 10.65. t1 t2 t3 gr write cycle gr address m ck address internal write signal input capture signal tcnt gr m figure 10.65 contention between general register write and input capture 10.6.9 note on waveform cycle setting when a counter is cleared by compare match, the counter is cleared in the last state in which the tcnt value matches the gr value (when the tcnt is updated from the matching count to the next count). the actual counter frequency is therefore given by the following formula: f = f /(n + 1) (f: counter frequency. f : operating frequency. n: value set in the gr.)
hitachi 293 10.6.10 contention between br write and input capture when a buffer register (br) is being used as an input capture register and an input capture signal is generated in the t3 state of the write cycle, the buffer operation takes priority over the br write. the timing is shown in figure 10.66. t1 t2 t3 br write cycle br address nx ck address internal write signal input capture signal gr br mn tcnt value figure 10.66 contention between br write and input capture
294 hitachi 10.6.11 note on writing in the synchronizing mode after the synchronizing mode is selected, if the tcnt is written by byte access, all 16 bits of all synchronized counters assume the same value as the counter that was addressed. example: figures 10.67 and 10.68 show byte write and word write when channels 2 and 3 are synchronized ax tcnt2 ax tcnt3 ya tcnt2 ya tcnt3 write a to lower byte of channel 3 write a to upper byte of channel 2 wx tcnt2 yz tcnt3 upper byte lower byte upper byte lower byte upper byte lower byte figure 10.67 byte write to channel 2 or byte write to channel 3 ab tcnt2 ab tcnt3 word write of ab for channel 2 or 3 wx tcnt2 yz tcnt3 upper byte lower byte upper byte lower byte figure 10.68 word write to channel 2 or word write to channel 3 10.6.12 note on setting reset-synchronized pwm mode/complementary pwm mode when the cmd1 and cmd0 bits of tfcr are set, note the following. 1. writes to cmd1 and cmd0 should be done while tcnt3 and tcnt4 are halted. 2. changes of setting from the reset-synchronized pwm mode to the complementary pwm mode and vice versa are inhibited. set the reset-synchronized pwm mode or complementary pwm mode after first setting normal operation (clear cmd1 bit to 0).
hitachi 295 10.6.13 clearing the complementary pwm mode figure 10.69 shows the procedure for clearing the complementary pwm mode. first, reset the combination mode bits cmd1 and cmd0 in the timer function control register (tfcr) from 10 to either 00 or 01. the mode will switch from complementary pwm mode to normal operating mode. next, wait for at least 1 clock of the counter input clock being used for channels 3 and 4 and then clear the counter start bits str3 and str4 of the timer start register (tstr). the channels 3 and 4 counters tcnt3 and tcnt4 will stop counting. clearing the complementary pwm mode by any other procedure may result in changes other than those set for the output waveform when complementary pwm mode is set again. 1. clear the cmd1 bit of the tfcr to 0 to set channels 3 and 4 for normal operation complementary pwm mode clear complementary pwm mode halt count 2. wait at least 1 clock after setting channels 3 and 4 for normal operation and then clear the str3 and str4 bits of the tstr to 0 to halt the tcnt3 and tcnt4 counters normal operation figure 10.69 clearing the complementary pwm mode 10.6.14 itu operating modes tables 10.18?0.22 show the itu operating modes for channels 0?. 10.6.15 note on counter clearing by input capture if tcnt is cleared (to h'0000) by input capture when its value is h'ffff, overflow will not occur.
296 hitachi table 10.18 itu operating modes (channel 0) register setting tsnc tmdr tfcr tocr tior0 tcr0 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized preset sync0 = 1 ? ?? ?? pwm ? pwm0 = 1 ??? output compare a function ? pwm0 = 0 ioa2 = 0, others free ??? output compare b function ? ? ? iob2 = 0, others free ?? input capture a function ? pwm0 = 0 ioa2 = 1, others free ??? input capture b function ? pwm0 = 0 ? iob2 = 1, others free ?? counter clear function clear at compare match/ input capture a ? ? ?? cclr1 = 0 cclr0 = 1 ? clear at compare match/ input capture b ? ? ?? cclr1 = 1 cclr0 = 0 ? synch- ronized clear sync0 = 1 ? ?? cclr1 = 1 cclr0 = 1 ? ? : settable, ? setting does not affect current mode note: in pwm mode, the input capture function cannot be used. when compare match a and compare match b occur simultaneously, the compare match signal is inhibited.
hitachi 297 table 10.19 itu operating modes (channel 1) register setting tsnc tmdr tfcr tocr tior1 tcr1 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized preset sync1 = 1 ? ?? ?? pwm ? pwm1 = 1 ? * 1 ?? output compare a function ? pwm1 = 0 ioa2 = 0, others free ??? output compare b function ? ? ? iob2 = 0, others free ?? input capture a function ? pwm1 = 0 ioa2 = 1, others free ??? input capture b function ? pwm1 = 0 ? iob2 = 1, others free ?? counter clear function clear at compare match/ input capture a ? ? ?? cclr1 = 0 cclr0 = 1 ? clear at compare match/ input capture b ? ? ?? cclr1 = 1 cclr0 = 0 ? synch- ronized clear sync1 = 1 ? ?? cclr1 = 1 cclr0 = 1 ? ? : settable, ? setting does not affect current mode note: in pwm mode, the input capture function cannot be used. when compare match a and compare match b occur simultaneously, the compare match signal is inhibited.
298 hitachi table 10.20 itu operating modes (channel 2) register setting tsnc tmdr tfcr tocr tior2 tcr2 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized preset sync2 = 1 ? ?? ?? pwm ? pwm2 = 1 ??? output compare a function ? pwm2 = 0 ioa2 = 0, others free ??? output compare b function ? ? ? iob2 = 0, others free ?? input capture a function ? pwm2 = 0 ioa2 = 1, others free ??? input capture b function ? pwm2 = 0 ? iob2 = 1, others free ?? counter clear function clear at compare match/ input capture a ? ? ?? cclr1 = 0 cclr0 = 1 ? clear at compare match/ input capture b ? ? ?? cclr1 = 1 cclr0 = 0 ? synch- ronized clear sync2 = 1 ? ?? cclr1 = 1 cclr0 = 1 ? phase counting ? mdf = 1 ?? ?? ? ? : settable, ? setting does not affect current mode
hitachi 299 note: in pwm mode, the input capture function cannot be used. when compare match a and compare match b occur simultaneously, the compare match signal is inhibited. table 10.21 itu operating modes (channel 3) register setting tsnc tmdr tfcr tocr tior3 tcr3 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized preset sync3 = 1 ?? * 2 ?? ?? ?? pwm mode ? pwm3 = 1 cmd1 = 0 cmd1 = 0 ? ? * 1 ?? output compare a function ? pwm3 = 0 cmd1 = 0 cmd1 = 0 ? ioa2 = 0, others free ??? output compare b function ? ? cmd1 = 0 cmd1 = 0 ? ? iob2 = 0, oth- ers free ?? input capture a function ? pwm3 = 0 cmd1 = 0 cmd1 = 0 ? ioa2 = 1, others free ??? input capture b function ? pwm3 = 0 cmd1 = 0 cmd1 = 0 ? ? iob2 = 1, oth- ers free ?? counter clear function clear at compare match/ input capture a ? ? cmd1 = 1, cmd0 = 0 inhib- ited ? * 3 ? ?? cclr1 = 0 cclr0 = 1 ? clear at compare match/ input capture b ? ? cmd1 = 0 cmd1 = 0 ? ?? cclr1 = 1 cclr0 = 0 ? synch- ronized clear sync3 = 1 ? cmd1 = 1, cmd0 = 0 inhib- ited ?? ?? cclr1 = 1 cclr0 = 1 ?
300 hitachi table 10.21 itu operating modes (channel 3) (cont) counter clear function register setting tsnc tmdr tfcr tocr tior3 tcr3 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select comple- mentary pwm mode ? * 2 cmd1 = 1 cmd0 = 0 cmd1 = 1 cmd0 = 0 ?? cclr1 = 0 cclr0 = 0 ? * 4 reset synchron- ized pwm mode ? cmd1 = 1 cmd0 = 1 cmd1 = 1 cmd0 = 1 ?? cclr1 = 0 cclr0 = 1 ? buffer (bra) ? ??? bfa3 = 1, others free ???? buffer (brb) ? ??? bfb3 = 1, others free ???? ? : settable, ? setting does not affect current mode notes: 1. in pwm mode, the input capture function cannot be used. when compare match a and compare match b occur simultaneously, the compare match signal is inhibited. 2. when set for complementary pwm mode, do not simultaneously set channel 3 and channel 4 to function synchronously. 3. counter clearing by input capture a cannot be used when the reset-synchronized pwm mode is set. 4. clock selection when the complementary pwm mode is set should be the same for channels 3 and 4.
hitachi 301 table 10.22 itu operating modes (channel 4) register setting tsnc tmdr tfcr tocr tior4 tcr4 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized preset sync4 = 1 ?? * 2 ?? ?? ?? pwm ? pwm4 = 1 cmd1 = 0 cmd1 = 0 ? ? * 1 ?? output compare a function ? pwm4 = 0 cmd1 = 0 cmd1 = 0 ? ioa2 = 0, others free ??? output compare b function ? ? cmd1 = 0 cmd1 = 0 ? ? iob2 = 0, others free ?? input capture a function ? pwm4 = 0 cmd1 = 0 cmd1 = 0 ? ioa2 = 1, others free ??? input capture b function ? pwm4 = 0 cmd1 = 0 cmd1 = 0 ? ? iob2 = 1, others free ?? counter clear function clear at compare match/ input capture a ? ? cmd1 = 1, cmd0 = 0 inhibit ed ? * 3 ? ?? cclr1 = 0 cclr0 = 1 ? clear at compare match/ input capture b ? ? cmd1 = 1, cmd0 = 0 inhibit ed ? * 3 ? ?? cclr1 = 1 cclr0 = 0 ?
302 hitachi table 10.22 itu operating modes (channel 4) (cont) counter clear function register setting tsnc tmdr tfcr tocr tior4 tcr4 operating mode sync mdf fdir pwm comp pwm reset sync pwm buf- fer output level select ioa iob clear select clock select synch- ronized clear sync4 = 1 ? cmd1 = 1, cmd1 = 0 inhibit ed ? * 3 ? ?? cclr1 = 1 cclr0 = 1 ? comple- mentary pwm ? * 2 cmd1 = 1 cmd0 = 0 cmd1 = 1 cmd0 = 0 ?? cclr1 = 0 cclr0 = 0 ? * 4 reset synchron- ized pwm ? cmd1 = 1 cmd0 = 1 cmd1 = 1 cmd0 = 1 ?? ? * 5 ? * 5 buffer (bra) ? ??? bfa4 = 1, others free ???? buffer (brb) ? ??? bfb4 = 1, others free ???? ? : settable, ? setting does not affect current mode notes: 1. in pwm mode, the input capture function cannot be used. when compare match a and compare match b occur simultaneously, the compare match signal is inhibited. 2. when set for complementary pwm mode, do not simultaneously set channel 3 and channel 4 to function synchronously. 3. counter clearing works with the reset-synchronized pwm mode, but tcnt4 runs independently. the output waveform is not affected. 4. clock selection when the complementary pwm mode is set should be the same for channels 3 and 4. 5. in the reset-synchronized pwm mode, tcnt4 runs independently. the output waveform is not affected.
hitachi 303 section 11 programmable timing pattern controller (tpc) 11.1 overview the superh microcomputer has a built-in programmable timing pattern controller (tpc). the tpc can provide pulse outputs by using the 16-bit integrated-timer pulse unit (itu) as a time base. the tpc pulse outputs are divided into 4-bit groups 3?. these can operate simultaneously, or independently. 11.1.1 features features of the programmable timing pattern controller are listed below. 16-bit output data: maximum 16-bit data can be output. tpc output can be enabled on a bit- by-bit basis. four output groups: output trigger signals can be selected in 4-bit groups to provide up to four different 4-bit outputs. selectable output trigger signals: output trigger signals can be selected by group from the 4-channel compare-match signals of the 16-bit integrated-timer pulse unit (itu). non-overlap mode: a non-overlap interval can be set to come between multiple pulse outputs. can connect to dma controller: the compare-match signals selected as output trigger signals can activate the dma controller for sequential output of data without cpu intervention.
304 hitachi 11.1.2 block diagram figure 11.1 is the block diagram of the tpc. pbcr1 ndera tpmr pbcr2 nderb tpcr pbdr control logic pulse output pin group 3 pulse output pin group 2 pulse output pin group 1 pulse output pin group 0 itu compare match signal tp15 tp14 tp13 tp12 tp11 tp10 tp9 tp8 tp7 tp6 tp5 tp4 tp3 tp2 tp1 tp0 internal data bus ndrb ndra tpc tpmr: tpc output mode register pbcr1: port b control register 1 tpcr: tpc output control register pbcr2: port b control register 2 nderb: next data enable register b ndrb: next data register b ndera: next data enable register a ndra: next data register a pbdr: port b data register figure 11.1 tpc block diagram
hitachi 305 11.1.3 input/output pins table 11.1 summarizes the tpc input/output pins. table 11.1 tpc pins name symbol input/output function tpc output 0 tp0 output group 0 pulse output tpc output 1 tp1 output tpc output 2 tp2 output tpc output 3 tp3 output tpc output 4 tp4 output group 1 pulse output tpc output 5 tp5 output tpc output 6 tp6 output tpc output 7 tp7 output tpc output 8 tp8 output group 2 pulse output tpc output 9 tp9 output tpc output 10 tp10 output tpc output 11 tp11 output tpc output 12 tp12 output group 3 pulse output tpc output 13 tp13 output tpc output 14 tp14 output tpc output 15 tp15 output
306 hitachi 11.1.4 registers table 11.2 summarizes the tpc registers. table 11.2 tpc registers name abbreviation r/w initial value address* 1 access size` port b control register 1 pbcr1 r/w h'0000 h'5ffffcc 8, 16 port b control register 2 pbcr2 r/w h'0000 h'5ffffce 8, 16 port b data register pbdr r/(w)* 2 h'0000 h'5ffffc2 8, 16 tpc output mode register tpmr r/w h'f0 h'5fffff0 8, 16 tpc output control register tpcr r/w h'ff h'5fffff1 8, 16 next data enable register b nderb r/w h'00 h'5fffff2 8, 16 next data enable register a ndera r/w h'00 h'5fffff3 8, 16 next data register a ndra r/w h'00 h'5fffff5/ h'5fffff7* 3 8, 16 next data register b ndrb r/w h'00 h'5fffff4/ h'5fffff6* 3 8, 16 notes: 1. only the values of bits a27?24 and a8?0 are valid; bits a23?9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 2. bits used for tpc output cannot be written to. 3. these addresses change depending on tpcr settings. when tpc output groups 0 and 1 have the same output trigger, the ndra address is h'5fffff5; when their output triggers are different, the ndra address for group 0 is h'5fffff7 and the address for group 1 is h'5fffff5. likewise, when tpc output groups 2 and 3 have the same output trigger, the ndrb address is h'5fffff4; when their output triggers are different, the ndrb address for group 0 is h'5fffff6 and the address for group 1 is h'5fffff4. 11.2 register descriptions 11.2.1 port b control registers 1 and 2 (pbcr1, pcbr2) the port b control register 1 and 2 (pbcr1 and pbcr2) are 16-bit read/write registers that set the functions of port b pins. port b consists of the dual use pins tp15?p0. bits corresponding to the pins to be used for tpc output must be set to 1. for details, see the port b description in the section 15, pin function controller.
hitachi 307 pcbr1: bit: 15 14 13 12 11 10 9 8 bit name: pb15 md1 pb15 md0 pb14 md1 pb14 md0 pb13 md1 pb13 md0 pb12 md1 pb12 md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb11 md1 pb11 md0 pb10 md1 pb10 md0 pb9md1 pb9md0 pb8md1 pb8md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w pcbr2: bit: 15 14 13 12 11 10 9 8 bit name: pb7md1 pb7md0 pb6md1 pb6md0 pb5md1 pb5md0 pb4md1 pb4md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb3md1 pb3md0 pb2md1 pb2md0 pb1md1 pb1md0 pb0md1 pb0md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 11.2.2 port b data register (pbdr) the port b data register is a 16-bit read/write register that, when used for tpc output stores, output data for groups 0?. for details, see the port b description in section 16, i/o ports. bit: 15 14 13 12 11 10 9 8 bit name: pb15dr pb14dr pb13dr pb12dr pb11dr pb10dr pb9dr pb8dr initial value: 0 0 0 0 0 0 0 0 r/w: r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* note: bits set to tpc output by ndera or nderb are read-only.
308 hitachi bit: 7 6 5 4 3 2 1 0 bit name: pb7dr pb6dr pb5dr pb4dr pb3dr pb2dr pb1dr pb0dr initial value: 0 0 0 0 0 0 0 0 r/w: r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* note: bits set to tpc output by ndera or nderb are read-only. 11.2.3 next data register a (ndra) ndra is an eight-bit read/write register that stores the next output data for tpc output groups 1 and 0 (tp7?p0). when used for tpc output, the contents of the ndra are transferred to the corresponding pbdr bits when the itu compare match specified in the tpc output control register tpcr occurs. the address of the ndra differs depending on whether tpcr settings select the same trigger or different triggers for tpc output groups 1 and 0. when reset, ndra is initialized to h'00. it is not initialized by standby mode. same trigger for tpc output groups 1 and 0: if tpc output groups 1 and 0 are triggered by the same compare match, the address of the ndra is h'fffff5. the 4 upper bits becomes group 1 and the 4 lower bits become group 0. address h'5fffff7 in such cases consists entirely of reserved bits. these bits cannot be modified and always read as 1. address h'5fffff5: bits 7? (next data 7? (ndr7?dr4)): ndr7-ndr4 store the next output data for tpc output group 1. bits 3? (next data 3? (ndr3?dr0)): ndr3-ndr0 store the next output data for tpc output group 0. bit: 7 6 5 4 3 2 1 0 bit name: ndr7 ndr6 ndr5 ndr4 ndr3 ndr2 ndr1 ndr0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w
hitachi 309 address h'5fffff7: bits 7? (reserved): these bits always read as 1. the write value should always be 1. bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: different triggers for tpc output groups 1 and 0: if tpc output groups 1 and 0 are triggered by different compare matches, the address of the upper 4 bits of ndra (group 1) is h'5fffff5 and the address of the lower 4 bits of ndra (group 0) is h'5fffff7. bits 3? of address h'5fffff5 and bits 7? of address h'5fffff7 are reserved bits. the write value should always be 1. these bits always read as 1. address h'5fffff5: bits 7? (next data 7? (ndr7?dr4)): ndr7?dr4 store the next output data for tpc output group 1. bits 3? (reserved): these bits always read as 1. the write value should always be 1. bit: 7 6 5 4 3 2 1 0 bit name: ndr7 ndr6 ndr5 ndr4 initial value: 0 0 0 0 1 1 1 1 r/w: r/w r/w r/w r/w address h'5fffff7: bits 7? (reserved): these bits always read as 1. the write value should always be 1. bits 3? (next data 3? (ndr3?dr0)): ndr3-ndr0 store the next output data for tpc output group 0. bit: 7 6 5 4 3 2 1 0 bit name: ndr3 ndr2 ndr1 ndr0 initial value: 1 1 1 1 0 0 0 0 r/w: r/w r/w r/w r/w
310 hitachi 11.2.4 next data register b (ndrb) ndrb is an eight-bit read/write register that stores the next output data for tpc output groups 3 and 2 (tp15?p8). when used for tpc output, the contents of the ndrb are transferred to the corresponding pbdr bits when the itu compare match specified in the tpc output control register tpcr occurs. the address of the ndrb differs depending on whether tpcr settings select the same trigger or different triggers for tpc output groups 3 and 2. when reset, ndrb is initialized to h'00. it is not initialized by standby mode. same trigger for tpc output groups 3 and 2: if tpc output groups 3 and 2 are triggered by the same compare match, the address of the ndrb is h'fffff4. the 4 upper bits becomes group 3 and the 4 lower bits become group 2. address h'5fffff6 becomes completely reserved bits. these bits always read as 1, and the write value should always be 1. address h'5fffff4: bits 7? (next data 15?2 (ndr15?dr12)): ndr15?dr12 store next output data for tpc output group 3. bits 3? (next data 11? (ndr11?dr8)): ndr11?dr8 store next output data for tpc output group 2. bit: 7 6 5 4 3 2 1 0 bit name: ndr15 ndr14 ndr13 ndr12 ndr11 ndr10 ndr9 ndr8 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w address h'5fffff6: bits 7? (reserved): these bits always read as 1. the write value should always be 1. bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w:
hitachi 311 different triggers for tpc output groups 3 and 2: if tpc output groups 3 and 2 are triggered by different compare matches, the address of the upper 4 bits of ndrb (group 3) is h'5fffff4 and the address of the lower 4 bits of ndrb (group 2) is h'5fffff6. bits 3-0 of address h'5fffff4 and bits 7? of address h'5fffff6 are reserved bits. these bits always read as 1. the write value should always be 1. address h'5fffff4: bits 7? (next data 15?2 (ndr15?dr12)): ndr15?dr12 store next output data for tpc output group 3. bits 3? (reserved): these bits always read as 1. the write value should always be 1. bit: 7 6 5 4 3 2 1 0 bit name: ndr15 ndr14 ndr13 ndr12 initial value: 0 0 0 0 1 1 1 1 r/w: r/w r/w r/w r/w address h'5fffff6: bits 7? (reserved): these bits always read as 1. the write value should always be 1. bits 3? (next data 11? (ndr11?dr8)): ndr11?dr8 store next output data for tpc output group 2. bit: 7 6 5 4 3 2 1 0 bit name: ndr11 ndr10 ndr9 ndr8 initial value: 1 1 1 1 0 0 0 0 r/w: r/w r/w r/w r/w 11.2.5 next data enable register a (ndera) ndera is an eight-bit read/write register that enables tpc output groups 1 and 0 (tp7?p0) on a bit-by-bit basis. when the bits enabled for tpc output by ndera generate the itu compare match selected in the tpc output control register, the value of the next data register a (ndra) is automatically transferred to the corresponding pbdr bits and the output value is updated. for disabled bits, there is no transfer and the output value does not change. when reset, ndera is initialized to h'00. it is not initialized by standby mode.
312 hitachi bit: 7 6 5 4 3 2 1 0 bit name: nder7 nder6 nder5 nder4 nder3 nder2 nder1 nder0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 7? (next data enable 7? (nder7?der0)): nder7?der0 select enable/disable for tpc output groups 1 and 0 (tp7?p0) in bit units. bit 7?: nder7?der0 description 0 disables tpc outputs tp7?p0 (transfer from ndr7?dr0 to pb7 pb0 is disabled) (initial value) 1 enables tpc outputs tp7?p0 (transfer from ndr7?dr0 to pb7 pb0 is enabled) 11.2.6 next data enable register b (nderb) nderb is an eight-bit read/write register that enables tpc output groups 3 and 2 (tp15?p8) on a bit-by-bit basis. when the bits enabled for tpc output by nderb generate the itu compare match selected in the tpc output control register, the value of the next data register b (ndrb) is automatically transferred to the corresponding pbdr bits and the output value is updated. for disabled bits, there is no transfer and the output value does not change. when reset, nderb is initialized to h'00. it is not initialized by standby mode. bit: 7 6 5 4 3 2 1 0 bit name: nder15 nder14 nder13 nder12 nder11 nder10 nder9 nder8 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 7? (next data enable 15? (nder15?der8)): nder15?der8 select enable/disable for tpc output groups 3 and 2 (tp15?p8) in bit units. bit 7?: nder15?der8 description 0 disables tpc outputs tp15?p8 (transfer from ndr15?dr8 to pb15?b8 is disabled) (initial value) 1 enables tpc outputs tp15?p8 (transfer from ndr15?dr8 to pb15?b8 is enabled)
hitachi 313 11.2.7 tpc output control register (tpcr) tpcr is an eight-bit read/write register that selects output trigger signals for tpc outputs. when reset, tpcr is initialized to h'ff. it is not initialized by standby mode. bit: 7 6 5 4 3 2 1 0 bit name: g3cms1 g3cms0 g2cms1 g2cms0 g1cms1 g1cms0 g0cms1 g0cms0 initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 7 and 6 (group 3 compare-match select 1 and 0 (g3cms1 and g3cms0)): g3cms1 and g3cms0 select the compare match that triggers tpc output group 3 (tp15?p12). bit 7: g3cms1 bit 6: g3cms0 description 0 0 tpc output group 3 (tp15?p12) output is triggered by compare-match in itu channel 0 1 tpc output group 3 (tp15?p12) output is triggered by compare-match in itu channel 1 1 0 tpc output group 3 (tp15?p12) output is triggered by compare-match in itu channel 2 1 tpc output group 3 (tp15?p12) output is triggered by compare-match in itu channel 3 (initial value) bits 5 and 4 (group 2 compare-match select 1 and 0 (g2cms1 and g2cms0)): g2cms1 and g2cms0 select the itu channel that triggers tpc output group 2 (tp11?p8). bit 5: g2cms1 bit 4: g2cms0 description 0 0 tpc output group 2 (tp11?p18) output is triggered by compare-match in itu channel 0 1 tpc output group 2 (tp11?p18) output is triggered by compare-match in itu channel 1 1 0 tpc output group 2 (tp11?p18) output is triggered by compare-match in itu channel 2 1 tpc output group 2 (tp11?p18) output is triggered by compare-match in itu channel 3 (initial value)
314 hitachi bits 3 and 2 (group 1 compare-match select 1 and 0 (g1cms1 and g1cms0)): g1cms1 and g1cms0 select the itu channel that triggers tpc output group 1 (tp7?p4). bit 3: g1cms1 bit 2: g1cms0 description 0 0 tpc output group 1 (tp7?p4) output is triggered by compare-match in itu channel 0 1 tpc output group 1 (tp7?p4) output is triggered by compare-match in itu channel 1 1 0 tpc output group 1 (tp7?p4) output is triggered by compare-match in itu channel 2 1 tpc output group 1 (tp7?p4) output is triggered by compare-match in itu channel 3 (initial value) bits 1 and 0 (group 0 compare-match select 1 and 0 (g0cms1 and g0cms0)): g0cms1 and g0cms0 select the itu channel that triggers tpc output group 0 (tp3?p0). bit 1: g0cms1 bit 0: g0cms0 description 0 0 tpc output group 0 (tp3?p0) output is triggered by compare-match in itu channel 0 1 tpc output group 0 (tp3?p0) output is triggered by compare-match in itu channel 1 1 0 tpc output group 0 (tp3?p0) output is triggered by compare-match in itu channel 2 1 tpc output group 0 (tp3?p0) output is triggered by compare-match in itu channel 3 (initial value) 11.2.8 tpc output mode register (tpmr) tpmr is an eight-bit read/write register that selects between the tpc's ordinary output and non- overlap output modes in group units. during non-overlap operation, the output waveform cycle is set in itu general register b (grb) for use as the output trigger and a non-overlap period is set in general register a (gra). the output value then changes on compare matches a and b. for details, see section 11.3.4, tpc output non-overlap operation. tpmr is initialized to h'f0 on a reset. it is not initialized in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: g3nov g2nov g1nov g0nov initial value: 1 1 1 1 0 0 0 0 r/w: r/w r/w r/w r/w
hitachi 315 bits 7? (reserved): these bits always read as 1. the write value should always be 1. bit 3 (group 3 non-overlap mode (g3nov)): g3nov selects the ordinary or non-overlap mode for tpc output group 3 (tp15?p12). bit 3: g3nov description 0 tpc output group 3 operates normally (output value updated according to compare-match a of the itu channel selected by tpcr) (initial value) 1 tpc output group 3 operates in non-overlap mode (1 output and 0 output can be performed independently according to compare-match a and b of the itu channel selected by tpcr) bit 2 (group 2 non-overlap mode (g2nov)): g2nov selects the ordinary or non-overlap mode for tpc output group 2 (tp11?p8). bit 2: g2nov description 0 tpc output group 2 operates normally (output value updated according to compare-match a of the itu channel selected by tpcr) (initial value) 1 tpc output group 2 operates in non-overlap mode (1 output and 0 output can be performed independently according to compare-match a and b of the itu channel selected by tpcr) bit 1 (group 1 non-overlap mode (g1nov)): g1nov selects the ordinary or non-overlap mode for tpc output group 1 (tp7?p4). bit 1: g1nov description 0 tpc output group 1 operates normally (output value updated according to compare-match a of the itu channel selected by tpcr) (initial value) 1 tpc output group 1 operates in non-overlap mode (1 output and 0 output can be performed independently according to compare-match a and b of the itu channel selected by tpcr) bit 0 (group 0 non-overlap mode (g0nov)): g0nov selects the ordinary or non-overlap mode for tpc output group 0 (tp3?p0).
316 hitachi bit 0: g0nov description 0 tpc output group 0 operates normally (output value updated according to compare-match a of the itu channel selected by tpcr) (initial value) 1 tpc output group 0 operates in non-overlap mode (1 output and 0 output can be performed independently according to compare-match a and b of the itu channel selected by tpcr) 11.3 operation 11.3.1 overview when corresponding bits in the pbcr1, pbcr2, ndera and nderb registers are set to 1, tpc output is enabled and the pbdr data register values are output. after that, when the compare- match event selected by tpcr occurs, the next data register contents (ndra and ndrb) are transferred to the pbdr and output values are updated. figure 11.2 illustrates the tpc output operation. cr q nder q tpc output pin port function select dr q c d ndr qd internal data bus output trigger signal figure 11.2 tpc output operation if new data is written in next data registers a and b before the next compare-match occurs, a maximum 16 bits of data can be output at each successive compare-match. see section 11.3.4, tpc output non-overlap operation, for details on non-overlap operation.
hitachi 317 11.3.2 output timing if tpc output is enabled, next data register (ndra/ndrb) contents are transferred to the data register (pbdr) and output when the selected compare-match occurs. figure 11.3 shows the timing of these operations. the example is of ordinary output upon compare match a with groups 2 and 3. n m ck tcnt gra compare match a signal ndrb n + 1 pbdr tp15?p8 n n mn n figure 11.3 transfer and output timing for ndr data 11.3.3 examples of use of ordinary tpc output settings for ordinary tpc output (figure 11.4): 1. select gra as the output compare register (output disable) with the timer i/o control register (tior). 2. set the tpc output trigger cycle. 3. select the counter clock with the tpsc2?psc0 bits of the timer control register (tcr). select the counter clear sources with the cclr1 and cclr0 bits. 4. set the timer interrupt enable register (tier) to enable imia interrupts. transfers to the ndr can also be set using the dmac. 5. set the initial output value in the i/o port data register to be used by tpc. 6. set the i/o port control register to be used by tpc as the tp pin function (11).
318 hitachi 7. set to 1 the bit that performs tpc output to the next data enable register (nder). 8. select the itu compare match that will be the tpc output trigger using the tpc output control register (tpcr). 9. set the next tpc output value in the ndr. 10. set 1 in the str bit of the timer start register (tstr) and start the timer counter counting. 11. set the next output value in the ndr whenever an imia interrupt is generated. yes no set count operation set gra select gr function itu setting port and tpc setting itu setting (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) (11) compare match? original tpc output operation set next tpc output value set next tpc output value start count select tpc output trigger set tpc output enable set port output set initial output value select interrupt request figure 11.4 example of setting procedure for tpc ordinary output
hitachi 319 five-phase pulse output (figure 11.5): 1. set the gra of the itu that serves as output trigger as the output compare register. set the cycle time in the gra of the itu and select to clear the counter upon compare match a. set the imiea bit of tier to 1 to enable the compare match a interrupt. 2. write h'ffc0 in the pbcr1, write h'f8 in the nderb, and set g3cms0, g3cms1, g2cms1 and g2cms0 in the tpcr to set the itu compare match selected in step 1 as the output trigger. write output data h'80 in the ndrb. 3. when the selected itu channel starts operating and a compare-match occurs, the values in the ndrb are transferred to the pbdr and output. the compare-match/input capture a (imia) interrupt service routine writes the next output data (h'c0) in the ndrb. 4. five-phase pulse output can be obtained by writing h'40, h'60, h'20, h'30, h'10, h'18, h'08, h'88?at successive compare-match interrupts. if the dma controller is set for activation by compare-match, pulse output can be obtained without loading the cpu. tcnt value tcnt compare matches gra 8000 c000 4000 6000 2000 3000 1000 1800 0800 8800 8000 c000 time h'0000 ndrb pbdr tp15 tp14 tp13 tp12 tp11 80 c0 40 60 20 30 10 18 08 88 80 c0 figure 11.5 tpc output example (5-phase pulse output)
320 hitachi 11.3.4 tpc output non-overlap operation setting procedures for tpc output non-overlap operation (figure 11.6): 1. select gra and grb as output compare registers (output disable) with the timer i/o control register (tior). 2. set the tpc output trigger cycle to grb and the non-overlap cycle to gra. 3. select the counter clock with the tpsc2?psc0 bits of the timer control register (tcr). select the counter clear sources with the cclr1 and cclr0 bits. 4. set the timer interrupt enable register (tier) to enable imia interrupts. transfers to the ndr can also be set using the dmac. 5. set the initial output value in the i/o port data register to be used by tpc. 6. set the i/o port control register to be used by tpc as the tp pin function (11). 7. set to 1 the bit that performs tpc output to the next data enable register (nder). 8. select the itu compare match that will be the tpc output trigger using the tpc output control register (tpcr). 9. select the group that performs the non-overlap operation in the tpc output mode register (tpmr). 10. set the next tpc output value in the ndr. 11. set 1 in the str bit of the timer start register (tstr) and start the timer counter counting. 12. set the next output value in the ndr whenever an imia interrupt is generated.
hitachi 321 itu setting port and tpc setting itu setting yes no start count set tpc output set count operation set gra select gr function (1) (2) (3) (4) (5) (6) (7) (8) (9) (11) (12) compare match a? (10) select interrupt request set tpc transfer enable select tpc output trigger select non-overlap group set next tpc output value tpc output non- overlap operation set next tpc output value set initial output value figure 11.6 example of setting procedures for tpc output non-overlap operation
322 hitachi tpc output non-overlap operation (four-phase complementary non-overlap output) (figure 11.7): 1. set gra and grb of the itu that serves as output trigger in the output compare registers. set the cycle in the grb and the non-overlap cycle time in the gra and select to clear the counter upon compare match b. set the imiea bit of tier to 1 to enable the imia interrupt. 2. write h'ffff in the pbcr1, write h'ff in the nderb, and set g3cms1, g3cms0, g2cms1 and g2cms0 in the tpcr to set the itu compare match selected in step 1 as the output trigger. set the g3nov and g2nov bits in the tpmr to 1 to set the non-overlap operation. write output data h'95 in the ndrb. 3. when the selected itu channel starts operating and a grb compare-match occurs, 1 output changes to 0 output; when a gra compare match occurs, 0 output changes to 1 output. (the change from 0 output to 1 output is delayed by the value set in gra.) the imia interrupt service routine writes the next output data (h'65) in the ndrb. 4. four-phase complementary non-overlap output can be obtained by writing h'59, h'56, h'95 at successive imia interrupts. if the dma controller is set for activation by compare-match, pulse output can be obtained without loading the cpu.
hitachi 323 95 65 59 56 95 65 ndrb h'0000 gra grb pbdr tp15 tp14 tp13 tp12 tp11 tp9 tp8 tp10 tcnt value tcnt 00 95 05 65 41 59 50 56 14 95 05 65 time non-overlap cycle figure 11.7 non-overlap output example (four-phase complementary output)
324 hitachi 11.3.5 tpc output by input capture tpc can also be output by using input capture rather than itu compare matches. the general register a (gra) of the itu selected by the tpcr functions as an input capture register and tpc output occurs upon an input capture signal. figure 11.8 shows the timing. mn n ck tioc pin input capture signal ndr dr figure 11.8 tpc output by input capture
hitachi 325 11.4 usage notes 11.4.1 non-overlap operation during non-overlap operation, transfers from the ndr to data registers (dr) occurs as follows. 1. ndr contents are always transferred to the dr on compare match a. 2. the contents of the bit transferred by the ndr are only transferred on compare match b when they are 0. no transfer occurs for a 1. figure 11.9 illustrates the tpc output operation during non-overlap. cr q nder q tpc output pin port function select dr q c d ndr qd compare match a compare match b figure 11.9 tpc output non-overlap operation
326 hitachi when a compare match b occurs before the compare match a, the 0 data transfer can be performed before the 1 data transfer, so a non-overlapping waveform can be output. in such cases, be sure not to change the ndr contents until the compare match a after the compare match b occurs (non-overlap period). this can be ensured by writing the next data to the ndr using the imia interrupt service routine. the dmac can also be started up using an imia interrupt. however, these write operations should be performed prior to the next compare match b. the timing is shown in figure 11.10. compare match a compare match b ndr dr ndr write ndr write 0/1 output 0 output ndr write disable period ndr write period 0/1 output 0 output ndr write disable period ndr write period figure 11.10 non-overlap operation and ndr write timing
hitachi 327 section 12 watchdog timer (wdt) 12.1 overview the superh microcomputer has a one-channel watchdog timer (wdt) for monitoring system operations. if a system becomes uncontrolled and the timer counter overflows without being rewritten correctly by the cpu, an overflow signal ( wdtovf ) is output externally . the wdt can simultaneously generate an internal reset signal for the entire chip. when this watchdog function is not needed, the wdt can be used as an interval timer. in the interval timer operation, an interval timer interrupt is generated at each counter overflow. the wdt is also used in recovering from the standby mode. 12.1.1 features watchdog timer mode and interval timer mode can be selected. outputs wdtovf in the watchdog timer mode. when the counter overflows in the watchdog timer mode, overflow signal wdtovf is output externally. you can select whether or not to reset the chip internally when this happens. either the power-on reset or manual reset signal can be selected as the internal reset signal. generates interrupts in the interval timer mode. when the counter overflows, it generates an interval timer interrupt. used to clear the standby mode. selection of eight counter clock sources
hitachi 328 12.1.2 block diagram figure 12.1 is the block diagram of the wdt. f /2 f /64 f /128 f /256 f /512 f /1024 f /4096 f /8192 internal clock sources clock overflow clock select interrupt control reset control rstcsr tcnt tcsr module bus bus interface internal data bus iti (interrupt signal) wdtovf internal reset signal* wdt tcsr: timer control/status register tcnt: timer counter rstcsr: reset control/status register note: the internal reset signal can be generated by setting the register. the type of reset can be selected (power-on or manual resets). figure 12.1 wdt block diagram 12.1.3 pin configuration table 12.1 shows the pin configuration.
hitachi 329 table 12.1 pin configuration pin abbreviation i/o function watchdog timer overflow wdtovf o outputs the counter overflow signal in the watchdog mode 12.1.4 register configuration table 12.2 summarizes the three wdt registers. they are used to select the clock, switch the wdt mode, and control the reset signal. table 12.2 wdt registers address name abbreviation r/w initial value write* 1 read* 2 timer control/status register tcsr r/(w)* 3 h'18 h'5ffffb8 h'5ffffb8 timer counter tcnt r/w h'00 h'5ffffb9 reset control/status register rstcsr r/(w)* 3 h'3f h'5ffffba h'5ffffbb notes: 1. write by word transfer. it cannot be written in byte or long word. 2. read by byte transfer. it cannot be read in word or long word. 3. only 0 can be written in bit 7 to clear the flag. 12.2 register descriptions 12.2.1 timer counter (tcnt) the tcnt is an eight-bit readable and writable upcounter. the tcnt differs from other registers in that it is more difficult to write. see section 12.2.4, register access, for details. when the timer enable bit (tme) in the timer control/status register (tcsr) is set to 1, the timer counter starts counting pulses of an internal clock source selected by clock select bits 2? (cks2?ks0) in the tcsr. when the value of the tcnt overflows (changes from h'ff?'00), a watchdog timer overflow signal ( wdtovf ) or interval timer interrupt (iti) is generated, depending on the mode selected in the wt/ it bit of the tcsr. the tcnt is initialized to h'00 by a reset and when the tme bit is cleared to 0. it is not initialized in the standby mode.
hitachi 330 bit: 7 6 5 4 3 2 1 0 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 12.2.2 timer control/status register (tcsr) the timer control/status register (tcsr) is an eight-bit readable and writable register. the tcsr differs from other registers in being more difficult to write. see section 12.2.4, register access, for details. its functions include selecting the timer mode and clock source. bits 7? are initialized to 000 by a reset or in standby mode. bits 2? are initialized to 000 by a reset, but retain their values in the standby mode. bit: 7 6 5 4 3 2 1 0 bit name: ovf wt/ it tme cks2 cks1 cks0 initial value: 0 0 0 1 1 0 0 0 r/w: r/(w)* r/w r/w r/w r/w r/w bit 7 (overflow flag (ovf)): ovf indicates that the tcnt has overflowed from h'ff?'00. it is not set in the watchdog timer mode. bit 7: ovf description 0 no overflow of tcnt in interval timer mode (initial value) cleared by reading ovf, then writing 0 in ovf 1 tcnt overflow in the interval timer mode bit 6 (timer mode select (wt/ it )): wt/ it selects whether to use the wdt as a watchdog timer or interval timer. when the tcnt overflows, the wdt either generates an interval timer interrupt (iti) or generates a wdtovf signal, depending on the mode selected. bit 6: wt/it description 0 interval timer mode: interval timer interrupt to the cpu when tcnt overflows (initial value) 1 watchdog timer mode: wdtovf signal output externally when tcnt overflows. section 12.2.3, reset control/status register (rstcsr), describes in detail what happens when tcnt overflows in the watchdog timer mode. bit 5 (timer enable (tme)): tme enables or disables the timer.
hitachi 331 bit 5: tme description 0 timer disabled: tcnt is initialized to h'00 and count-up stops (initial value) 1 timer enabled: tcnt starts counting. a wdtovf signal or interrupt is generated when tcnt overflows. bits 4 and 3 (reserved): these bits always read as 1. the write value should always be 1. bits 2? (clock select 2? (cks2?ks0)): cks2?ks0 select one of eight internal clock sources for input to the tcnt. the clock signals are obtained by dividing the frequency of the system clock ( f ). description bit 2: cks2 bit 1: cks1 bit 0: cks0 clock source overflow interval* ( f = 20 mhz) 000 f /2 (initial value) 25.6 m s 001 f /64 819.2 m s 010 f /128 1.6 ms 011 f /256 3.3 ms 100 f /512 6.6 ms 101 f /1024 13.1 ms 110 f /4096 52.4 ms 111 f /8192 104.9 ms note: the overflow interval listed is the time from when the tcnt begins counting at h'00 until an overflow occurs. 12.2.3 reset control/status register (rstcsr) the rstcsr is an eight-bit readable and writable register that controls output of the reset signal generated by timer counter (tcnt) overflow and selects the internal reset signal type. the rstcsr differs from other registers in that it is more difficult to write. see section 12.2.4 register access, for details. rstcr is initialized to h'1f by input of a reset signal from the res pin, but is not initialized by the internal reset signal generated by the overflow of the wdt. it is initialized to h'1f in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: wovf rste rsts initial value: 0 0 0 1 1 1 1 1 r/w: r/(w)* r/w r/w note: only 0 can be written in bit 7 to clear the flag.
hitachi 332 bit 7 (watchdog timer overflow (wovf)): wovf indicates that the tcnt has overflowed (h'ff ? h'00) in the watchdog timer mode. it is not set in the interval timer mode. bit 7: wovf description 0 no tcnt overflow in watchdog timer mode (initial value) cleared when software reads wovf, then writes 0 in wovf 1 set by tcnt overflow in watchdog timer mode bit 6 (reset enable (rste)): rste selects whether to reset the chip internally if the tcnt overflows in the watchdog timer mode. bit 6: rste description 0 not reset when tcnt overflows (initial value). lsi not reset internally, but tcnt and tcsr reset within wdt. 1 reset when tcnt overflows bit 5 (reset select (rsts)): rsts selects the type of internal reset generated if the tcnt overflows in the watchdog timer mode. bit 5: rsts description 0 power-on reset initial value) 1 manual reset bits 4? (reserved): these bits always read as 1. the write value should always be 1.
hitachi 333 12.2.4 register access the watchdog timer? tcnt, tcsr, and rstcsr registers differ from other registers in that they are more difficult to write. the procedures for writing and reading these registers are given below. writing to the tcnt and tcsr: these registers must be written by a word transfer instruction. they cannot be written by byte transfer instructions. the tcnt and tcsr both have the same write address. the write data must be contained in the lower byte of the written word. the upper byte must be h'5a (for the tcnt) or h'a5 (for the tcsr) (figure 12.2). this transfers the write data from the lower byte to the tcnt or tcsr. writing to the tcnt 15 8 7 0 address: h'5ffffb8 h'5a write data writing to the tcsr 15 8 7 0 address: h'5ffffb8 h'a5 write data figure 12.2 writing to the tcnt and tcsr
hitachi 334 writing to the rstcsr: the rstcsr must be written by a word access to address h'5fffffba. it cannot be written by byte transfer instructions. procedures for writing 0 in wovf (bit 7) and for writing to rste (bit 6) and rsts (bit 5) are different, as shown in figure 12.3. to write 0 in the wovf bit, the write data must be h'a5 in the upper byte and h'00 in the lower byte. this clears the wovf bit to 0. the rste and rsts bits are not affected. to write to the rste and rsts bits, the upper byte must be h'5a and the lower byte must be the write data. the values of bits 6 and 5 of the lower byte are transferred to the rste and rsts bits, respectively. the wovf bit is not affected. writing 0 to the wovf bit 15 8 7 0 address: h'5ffffba h'a5 h'00 writing to the rste and rsts bits 15 8 7 0 address: h'5ffffba h'5a write data figure 12.3 writing to the rstcsr reading from the tcnt, tcsr, and rstcsr: tcnt, tcsr, and rstcsr are read like other registers. use byte transfer instructions. the read addresses are h'5ffffb8 for the tcsr, h'5ffffb9 for the tcnt, and h'5ffffbb for the rstcsr. 12.3 operation 12.3.1 operation in the watchdog timer mode to use the wdt as a watchdog timer, set the wt/ it and tme bits of the tcsr to 1. software must prevent tcnt overflow by rewriting the tcnt value (normally by writing h'00) before overflow occurs. if the tcnt fails to be rewritten and overflows due to a system crash or the like, a wdtovf signal is output (figure 12.4). the wdtovf signal can be used to reset external system devices. the wdtovf signal is output for 128 f clock cycles. if the rste bit in the rstcsr is set to 1, a signal to reset the chip will be generated internally simultaneous to the wdtovf signal when tcnt overflows. either a power-on reset or a manual reset can be selected by the rsts bit. the internal reset signal is output for 512 f clock cycles. when a watchdog reset is generated simultaneously with input at the res pin, the software distinguishes the res reset from the watchdog reset by checking the wovf bit in the rstcsr. the res reset takes priority. the wovf bit is cleared to 0.
hitachi 335 h'ff h'00 overflow wt/ it = 1 tme = 1 h'00 written in tcnt internal reset signal* wdtovf signal tcnt value wdtovf and internal reset generated wovf = 1 wt/ it = 1 tme = 1 h'00 written in tcnt time 512 f clock 128 f clock wt/ it : timer mode select bit tme: timer enable bit note: the internal reset signal is only generated when the rste bit is 1. figure 12.4 operation in the watchdog timer mode
hitachi 336 12.3.2 operation in the interval timer mode to use the wdt as an interval timer, clear wt/ it to 0 and set tme to 1. an interval timer interrupt (iti) is generated each time the timer counter overflows. this function can be used to generate interval timer interrupts at regular intervals (figure 12.5). h'ff tcnt value h'00 wt/ it = 0 tme = 1 iti iti iti iti time overflow overflow overflow overflow figure 12.5 operation in the interval timer mode 12.3.3 operation in the standby mode the watchdog timer has a special function to clear the standby mode with an nmi interrupt. when using the standby mode, set the wdt as described below. transition to the standby mode: the tme bit in the tcsr must be cleared to 0 to stop the watchdog timer counter before it enters the standby mode. the chip cannot enter the standby mode while the tme bit is set to 1. set bits cks2?ks0 so that the counter overflow interval is equal to or longer than the oscillation settling time. see section 20.3, ac characteristics, for the oscillation settling time. recovery from the standby mode: when an nmi request signal is received in standby mode, the clock oscillator starts running and the watchdog timer starts counting at the rate selected by bits cks2?ks0 before the standby mode was entered. when the tcnt overflows (changes from h'ff?'00), the system clock ( f ) is presumed to be stable and usable; clock signals are supplied to the entire chip and the standby mode ends. for details on the standby mode, see section 19, power down states.
hitachi 337 12.3.4 timing of setting the overflow flag (ovf) in the interval timer mode, when the tcnt overflows the ovf flag is set to 1 and an interval timer interrupt is requested (figure 12.6). h'ff h'00 ck tcnt overflow signal (internal signal) ovf figure 12.6 timing of setting the ovf 12.3.5 timing of setting the watchdog timer overflow flag (wovf) when the tcnt overflows the wovf bit of the rstcsr is set to 1 and a wdtovf signal is output. when the rste bit is set to 1, tcnt overflow enables an internal reset signal to be generated for the entire chip (figure 12.7). h'ff h'00 ck tcnt overflow signal (internal signal) wovf figure 12.7 timing of setting the wovf bit and internal reset
hitachi 338 12.4 usage notes 12.4.1 tcnt write and count up contention if a timer counter clock pulse is generated during the t3 state of a write cycle to the tcnt, the write takes priority and the timer counter is not incremented (figure 12.8). ck address internal write signal tcnt input clock tcnt nm tcnt address counter write data t1 t2 t3 tcnt write cycle figure 12.8 contention between tcnt write and increment 12.4.2 changing cks2-cks0 bit values if the values of bits cks2?ks0 are altered while the wdt is running, the count may increment incorrectly. always stop the watchdog timer (by clearing the tme bit to 0) before changing the values of bits cks2?ks0. 12.4.3 changing watchdog timer/interval timer modes to prevent incorrect operation, always stop the watchdog timer (by clearing the tme bit to 0) before switching between interval timer mode and watchdog timer mode.
hitachi 339 12.4.4 system reset with wdtovf if a wdtovf signal is input to the res pin, the lsi cannot initialize correctly. avoid logical input of the wdtovf output signal to the res input pin. to reset the entire system with the wdtovf signal, use the circuit shown in figure 12.9. reset input reset signal to entire system superh microprocessor res wdtovf figure 12.9 example of a system reset circuit with a wdtovf signal 12.4.5 internal reset with the watchdog timer if the rste bit is cleared to 0 in the watchdog timer mode, the lsi will not reset internally when a tcnt overflow occurs, but the tcnt and tcsr in wdt will reset.
hitachi 341 section 13 serial communication interface (sci) 13.1 overview the superh microcomputer has a serial communication interface (sci) with two independent channels. both channels are functionally identical. the sci supports both asynchronous and clocked synchronous serial communication. it also has a multiprocessor communication function for serial communication among two or more processors. 13.1.1 features asynchronous mode ? serial data communications are synched by start-stop in character units. the sci can communicate with a universal asynchronous receiver/transmitter (uart), an asynchronous communication interface adapter (acia), or any other chip that employs a standard asynchronous serial communication. it can also communicate with two or more other processors using the multiprocessor communication function. there are twelve selectable serial data communication formats. ? data length: seven or eight bits ? stop bit length: one or two bits ? parity: even, odd, or none ? multiprocessor bit: one or none ? receive error detection: parity, overrun, and framing errors ? break detection: by reading the rxd level directly when a framing error occurs clocked synchronous mode ? serial data communication is synchronized with a clock signal. the sci can communicate with other chips having a clocked synchronous communication function. there is one serial data communication format. ? data length: eight bits ? receive error detection: overrun errors full duplex communication: the transmitting and receiving sections are independent, so the sci can transmit and receive simultaneously. both sections use double buffering, so continuous data transfer is possible in both the transmit and receive directions. on-chip baud rate generator with selectable bit rates internal or external transmit/receive clock source: baud rate generator (internal) or sck pin (external) four types of interrupts: transmit-data-empty, transmit-end, receive-data-full, and receive- error interrupts are requested independently. the transmit-data-empty and receive-data-full interrupts can start the direct memory access controller (dmac) to transfer data.
hitachi 342 13.1.2 block diagram figure 13.1 shows a block diagram of the sci. parity generation parity check transmit/ receive control baud rate generator clock external clock bus interface internal data bus rxd rdr tdr rsr tsr ssr scr smr brr f f /4 f /16 f /64 tei txi rxi eri sck txd sci module data bus rsr: receive shift register smr: serial mode register rdr: receive data register scr: serial control register tsr: transmit shift register ssr: serial status register tdr: transmit data register brr: bit rate register figure 13.1 sci block diagram
hitachi 343 13.1.3 input/output pins table 13.1 summarizes the sci pins by channel. table 13.1 sci pins channel pin name abbreviation input/output function 0 serial clock pin sck0 input/output sci0 clock input/output receive data pin rxd0 input sci0 receive data input transmit data pin txd0 output sci0 transmit data output 1 serial clock pin sck1 input/output sci1 clock input/output receive data pin rxd1 input sci1 receive data input transmit data pin txd1 output sci1 transmit data output 13.1.4 register configuration table 13.2 summarizes the sci internal registers. these registers select the communication mode (asynchronous or clocked synchronous), specify the data format and bit rate, and control the transmitter and receiver sections. table 13.2 registers channel address* 1 name abbreviation r/w initial value access size 0 h'05fffec0 serial mode register smr0 r/w h'00 8, 16 h'05fffec1 bit rate register brr0 r/w h'ff 8, 16 h'05fffec2 serial control register scr0 r/w h'00 8, 16 h'05fffec3 transmit data register tdr0 r/w h'ff 8, 16 h'05fffec4 serial status register ssr0 r/(w)* 2 h'84 8, 16 h'05fffec5 receive data register rdr0 r h'00 8, 16 1 h'05fffec8 serial mode register smr1 r/w h'00 8, 16 h'05fffec9 bit rate register brr1 r/w h'ff 8, 16 h'05fffeca serial control register scr1 r/w h'00 8, 16 h'05fffecb transmit data register tdr1 r/w h'ff 8, 16 h'05fffecc serial status register ssr1 r/(w)* 2 h'84 8, 16 h'05fffecd receive data register rdr1 r h'00 8, 16 notes: 1. only the values of bits a27?24 and a8-a0 are valid; bits a23?9 are ignored. for details on the register addresses, see section 8.3.5, description of areas. 2. write 0 to clear flags.
hitachi 344 13.2 register descriptions 13.2.1 receive shift register the receive shift register (rsr) receives serial data. data input at the rxd pin are loaded into the rsr in the order received, lsb (bit 0) first. in this way the sci converts received data to parallel form. when one byte has been received, it is automatically transferred to the receive data register (rdr). the cpu cannot read or write the rsr directly. bit: 7 6 5 4 3 2 1 0 bit name: r/w: 13.2.2 receive data register the receive data register (rdr) stores serial receive data. the sci completes the reception of one byte of serial data by moving the received data from the receive shift register (rsr) into the rdr for storage. the rsr is then ready to receive the next data. this double buffering allows the sci to receive data continuously. the cpu can read but not write the rdr. the rdr is initialized to h'00 by a reset or in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: initial value: 0 0 0 0 0 0 0 0 r/w: r r r r r r r r 13.2.3 transmit shift register the transmit shift register (tsr) transmits serial data. the sci loads transmit data from the transmit data register (tdr) into the tsr, then transmits the data serially from the txd pin, lsb (bit 0) first. after transmitting one data byte, the sci automatically loads the next transmit data from the tdr into the tsr and starts transmitting again. if the tdre bit of the ssr is 1, however, the sci does not load the tdr contents into the tsr. the cpu cannot read or write the tsr directly. bit: 7 6 5 4 3 2 1 0 bit name: r/w:
hitachi 345 13.2.4 transmit data register the transmit data register (tdr) is an eight-bit register that stores data for serial transmission. when the sci detects that the transmit shift register (tsr) is empty, it moves transmit data written in the tdr into the tsr and starts serial transmission. continuous serial transmission is possible by writing the next transmit data in the tdr during serial transmission from the tsr. the cpu can always read and write the tdr. the tdr is initialized to h'ff by a reset or in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 13.2.5 serial mode register the serial mode register (smr) is an eight-bit register that specifies the sci serial communication format and selects the clock source for the baud rate generator. the cpu can always read and write the smr. the smr is initialized to h'00 by a reset or in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: c/ a chr pe o/ e stop mp cks1 cks0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit 7 (communication mode (c/ a )): c/ a selects whether the sci operates in the asynchronous or clocked synchronous mode. bit 7: c/a description 0 synchronous mode (initial value) 1 clocked synchronous mode
hitachi 346 bit 6 (character length (chr)): chr selects seven-bit or eight-bit data in the asynchronous mode. in the clocked synchronous mode, the data length is always eight bits, regardless of the chr setting. bit 6: chr description 0 eight-bit data (initial value) 1 seven-bit data. when seven-bit data is selected, the msb (bit 7) of the transmit data register is not transmitted. bit 5 (parity enable (pe)): pe selects whether to add a parity bit to transmit data and check the parity of receive data, in the asynchronous mode. in the clocked synchronous mode, a parity bit is neither added nor checked, regardless of the pe setting. bit 5: pe description 0 parity bit not added or checked (initial value) 1 parity bit added and checked. when pe is set to 1, an even or odd parity bit is added to transmit data, depending on the parity mode (o/ e ) setting. receive data parity is checked according to the even/odd (o/ e ) mode setting. bit 4 (parity mode (o/ e ): o/ e selects even or odd parity when parity bits are added and checked. the o/ e setting is used only in asynchronous mode and only when the parity enable bit (pe) is set to 1 to enable parity addition and check. the o/ e setting is ignored in the clocked synchronous mode, or in the asynchronous mode when parity addition and check is disabled. bit 4: o/ e description 0 even parity. if even parity is selected, the parity bit added to transmit data makes an even number of 1s in the transmitted character and parity bit combined. receive data must have an even number of 1s in the received character and parity bit combined (initial value). 1 odd parity. if odd parity is selected, the parity bit added to transmit data makes an odd number of 1s in the transmitted character and parity bit combined. receive data must have an odd number of 1s in the received character and parity bit combined.
hitachi 347 bit 3 (stop bit length (stop)): stop selects one or two bits as the stop bit length in the asynchronous mode. this setting is used only in the asynchronous mode. it is ignored in the clocked synchronous mode because no stop bits are added. in receiving, only the first stop bit is checked, regardless of the stop bit setting. if the second stop bit is 1, it is treated as a stop bit. if the second stop bit is 0, it is treated as the start bit of the next incoming character. bit 3: stop description 0 one stop bit. in transmitting, a single bit of 1 is added at the end of each transmitted character (initial value). 1 two stop bits. in transmitting, two bits of 1 are added at the end of each transmitted character. bit 2 (multiprocessor mode (mp)): mp selects multiprocessor format. when multiprocessor format is selected, settings of the parity enable (pe) and parity mode (o/ e ) bits are ignored. the mp bit setting is used only in the asynchronous mode; it is ignored in the clocked synchronous mode. for the multiprocessor communication function, see section 13.3.3, multiprocessor communication. bit 2: mp description 0 multiprocessor function disabled (initial value) 1 multiprocessor format selected bits 1 and 0 (clock select 1 and 0 (cks1 and cks0)): cks1 and cks0 select the internal clock source of the on-chip baud rate generator. four clock sources are available: f , f /4, f /16, and f /64. for further information on the clock source, bit rate register settings, and baud rate, see section 13.2.8, bit rate register. bit 1: cks1 bit 0: cks0 description 0 0 system clock ( f ) (initial value) 1 f /4 10 f /16 1 f /64
hitachi 348 13.2.6 serial control register the serial control register (scr) enables the sci transmitter/receiver, selects serial clock output in the asynchronous mode, enables and disables interrupts, and selects the transmit/receive clock source. the cpu can always read and write the scr. the scr is initialized to h'00 by a reset or in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: tie rie te re mpie teie cke1 cke0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit 7 (transmit interrupt enable (tie)): tie enables or disables the transmit-data-empty interrupt (txi) requested when the transmit data register empty bit (tdre) in the serial status register (ssr) is set to 1 due to transfer of serial transmit data from the tdr to the tsr. bit 7: tie description 0 transmit-data-empty interrupt request (txi) is disable. the txi interrupt request can be cleared by reading tdre after it has been set to 1, then clearing tdre to 0, or by clearing tie to 0 (initial value). 1 transmit-data-empty interrupt request (txi) is enabled bit 6 (receive interrupt enable (rie)): rie enables or disables the receive-data-full interrupt (rxi) requested when the receive data register full bit (rdrf) in the serial status register (ssr) is set to 1 due to transfer of serial receive data from the rsr to the rdr. also enables or disables receive-error interrupt (eri) requests. bit 6: rie description 0 receive-data-full interrupt (rxi) and receive-error interrupt (eri) requests are disabled. rxi and eri interrupt requests can be cleared by reading the rdrf flag or error flag (fer, per, or orer) after it has been set to 1, then clearing the flag to 0, or by clearing rie to 0 (initial value). 1 receive-data-full interrupt (rxi) and receive-error interrupt (eri) requests are enabled
hitachi 349 bit 5 (transmit enable (te)): te enables or disables the sci transmitter. bit 5: te description 0 transmitter disabled. the transmit data register empty bit (tdre) in the serial status register (ssr) is locked at 1 (initial value). 1 transmitter enabled. serial transmission starts when the transmit data register empty (tdre) bit in the serial status register (ssr) is cleared to 0 after writing of transmit data into the tdr. select the transmit format in the smr before setting te to 1. bit 4 (receive enable (re)): re enables or disables the sci receiver. bit 4: re description 0 receiver disabled (initial value). clearing re to 0 does not affect the receive flags (rdrf, fer, per, orer). these flags retain their previous values. 1 receiver enabled. serial reception starts when a start bit is detected in the asynchronous mode, or serial clock input is detected in the clocked synchronous mode. select the receive format in the smr before setting re to 1. bit 3 (multiprocessor interrupt enable (mpie)): mpie enables or disables multiprocessor interrupts. the mpie setting is used only in the asynchronous mode, and only if the multiprocessor mode bit (mp) in the serial mode register (smr) is set to 1 during reception. the mpie setting is ignored in the clocked synchronous mode or when the mp bit is cleared to 0. bit 3: mpie description 0 multiprocessor interrupts are disabled (normal receive operation) (initial value) mpe is cleared to 0 when: 1. mpie is cleared to 0, or 2. multiprocessor bit (mpb) is set to 1 in receive data. 1 multiprocessor interrupts are enabled: receive-data-full interrupt requests (rxi), receive-error interrupt requests (eri), and setting of the rdrf, fer, and orer status flags in the serial status register (ssr) are disabled until the multiprocessor bit is set to 1. the sci does not transfer receive data from the rsr to the rdr, does not detect receive errors, and does not set the rdrf, fer, and orer flags in the serial status register (ssr). when it receives data that includes mpb = 1, mpb is set to 1, and the sci automatically clears mpie to 0, generates rxi and eri interrupts (if the tie and rie bits in the scr are set to 1), and allows the fer and orer to be set.
hitachi 350 bit 2 (transmit-end interrupt enable (teie)): teie enables or disables the transmit-end interrupt (tei) requested if tdr does not contain new transmit data when the msb is transmitted. bit 2: teie description 0 transmit-end interrupt (tei) requests are disabled* (initial value) the tei request can be cleared by reading the tdre bit in the serial status register (ssr) after it has been set to 1, then clearing tdre to 0; by clearing the transmit end (tend) bit to 0; or by clearing the teie bit to 0. 1 transmit-end interrupt (tei) requests are enabled. bits 1 and 0 (clock enable 1 and 0 (cke1 and cke0)): cke1 and cke0 select the sci clock source and enable or disable clock output from the sck pin. depending on the combination of cke1 and cke0, the sck pin can be used for general-purpose input/output, serial clock output, or serial clock input. the cke0 setting is valid only in the asynchronous mode, and only when the sci is internally clocked (cke1 = 0). the cke0 setting is ignored in the clocked synchronous mode, or when an external clock source is selected (cke1 = 1). select the sci operating mode in the serial mode register (smr) before setting cke1 and cke0. for further details on selection of the sci clock source, see table 13.9 in section 13.3, operation. bit 1: cke1 bit 0: cke0 description* 1 0 0 synchronous mode internal clock, sck pin used for input pin (input signal is ignored or output pin output level is undefined) clocked synchronous mode internal clock, sck pin used for serial clock output* 2 0 1 synchronous mode internal clock, sck pin used for clock output* 3 clocked synchronous mode internal clock, sck pin used for serial clock output 1 0 synchronous mode external clock, sck pin used for clock input* 4 clocked synchronous mode external clock, sck pin used for serial clock input 1 1 synchronous mode external clock, sck pin used for clock input* 4 clocked synchronous mode external clock, sck pin used for serial clock input notes: 1. the sck pin is multiplexed with other functions. set the pin function controller (pfc) to select the sck function and the sck input/output of the sck pin. 2. initial value 3. the output clock frequency is the same as the bit rate. 4. the input clock frequency is 16 times the bit rate.
hitachi 351 13.2.7 serial status register the serial status register (ssr) is an 8-bit register containing multiprocessor bit values, and status flags that indicate sci operating status. the cpu can always read and write the ssr, but cannot write 1 in the status flags (tdre, rdrf, orer, per, and fer). these flags can be cleared to 0 only if they have first been read (after being set to 1). bits 2 (tend) and 1 (mpb) are read-only bits that cannot be written. the ssr is initialized to h'84 by a reset or in standby mode. bit: 7 6 5 4 3 2 1 0 bit name: tdre rdrf orer fer per tend mpb mpbt initial value: 1 0 0 0 0 1 0 0 r/w: r/(w)* r/(w)* r/(w)* r/(w)* r/(w)* r r r/w note: write 0 to clear flag. bit 7 (transmit data register empty (tdre)): tdre indicates that the sci has loaded transmit data from the tdr into the tsr and serial transmit new data can be written in the tdr. bit 7: tdre description 0 tdr contains valid transmit data tdre is cleared to 0 when: software reads tdre after it has been set to 1, then writes 0 in tdre the dmac writes data in tdr 1 tdr does not contain valid transmit data (initial value) tdre is set to 1 when: the chip is reset or enters standby mode the te bit in the serial control register (scr) is cleared to 0 tdr contents are loaded into tsr, so new data can be written in tdr
hitachi 352 bit 6 (receive data register full (rdrf)): rdrf indicates that rdr contains received data. bit 6: rdrf description 0 rdr does not contain valid received data (initial value) rdrf is cleared to 0 when: the chip is reset or enters standby mode software reads rdrf after it has been set to 1, then writes 0 in rdrf the dmac reads data from rdr 1 rdr contains valid received data. rdrf is set to 1 when serial data is received normally and transferred from rsr to rdr. note: the rdr and rdrf are not affected by detection of receive errors or by clearing of the re bit to 0 in the serial control register. they retain their previous contents. if rdrf is still set to 1 when reception of the next data ends, an overrun error (orer) occurs and the received data is lost. bit 5 (overrun error (orer)): indicates that data reception ended abnormally due to an overrun error. bit 5: orer description 0 receiving is in progress or has ended normally (initial value)* 1 orer is cleared to 0 when: the chip is reset or enters standby mode software reads orer after it has been set to 1, then writes 0 in orer 1 a receive overrun error occurred* 2 orer is set to 1 if reception of the next serial data ends when rdrf is set to 1 notes: 1. clearing the re bit to 0 in the serial control register does not affect the orer bit, which retains its previous value. 2. rdr continues to hold the data received before the overrun error, so subsequent receive data is lost. serial receiving cannot continue while orer is set to 1. in the clocked synchronous mode, serial transmitting is disabled.
hitachi 353 bit 4 (framing error (fer)): fer indicates that data reception ended abnormally due to a framing error in the asynchronous mode. bit 4: fer description 0 receiving is in progress or has ended normally. clearing the re bit to 0 in the serial control register does not affect the fer bit, which retains its previous value (initial value). fer is cleared to 0 when: the chip is reset or enters standby mode software reads fer after it has been set to 1, then writes 0 in fer 1 a receive framing error occurred. when the stop bit length is two bits, only the first bit is checked. the second stop bit is not checked. when a framing error occurs, the sci transfers the receive data into the rdr but does not set rdrf. serial receiving cannot continue while fer is set to 1. in the clocked synchronous mode, serial transmitting is also disabled. fer is set to 1 if the stop bit at the end of receive data is checked and found to be 0. bit 3 (parity error (per)): per indicates that data reception (with parity) ended abnormally due to a parity error in the asynchronous mode. bit 3: per description 0 receiving is in progress or has ended normally. clearing the re bit to 0 in the serial control register does not affect the per bit, which retains its previous value (initial value). per is cleared to 0 when: the chip is reset or enters standby mode software reads per after it has been set to 1, then writes 0 in per 1 a receive parity error occurred. when a parity error occurs, the sci transfers the receive data into the rdr but does not set rdrf. serial receiving cannot continue while per is set to 1. in the clocked synchronous mode, serial transmitting is also disabled. per is set to 1 if the number of 1s in receive data, including the parity bit, does not match the even or odd parity setting of the parity mode bit (o/ e ) in the serial mode register (smr).
hitachi 354 bit 2 (transmit end (tend)): tend indicates that when the last bit of a serial character was transmitted, the tdr did not contain new transmit data, so transmission has ended. tend is a read-only bit and cannot be written. bit 2: tend description 0 transmission is in progress tend is cleared to 0 when: software reads tdre after it has been set to 1, then writing 0 in tdre the dmac writes data in tdr 1 end of transmission (initial value) tend is set to 1 when: the chip is reset or enters standby mode te is cleared to 0 in the serial control register (scr) tdre is 1 when the last bit of a one-byte serial character is transmitted bit 1 (multiprocessor bit (mpb)): mpb stores the value of the multiprocessor bit in receive data when a multiprocessor format is selected for receiving in the asynchronous mode. the mpb is a read-only bit and cannot be written. bit 1: mpb description 0 multiprocessor bit value in receive data is 0. if re is cleared to 0 when a multiprocessor format is selected, the mpb retains its previous?alue (initial value). 1 multiprocessor bit value in receive data is 1 bit 0 (multiprocessor bit transfer (mpbt)): mpbt stores the value of the multiprocessor bit added to transmit data when a multiprocessor format is selected for transmitting in the asynchronous mode. the mpbt setting is ignored in the clocked synchronous mode, when a multiprocessor format is not selected, or when the sci is not transmitting. bit 0: mpbt description 0 multiprocessor bit value in transmit data is 0 (initial value) 1 multiprocessor bit value in transmit data is 1
hitachi 355 13.2.8 bit rate register (brr) the bit rate register (brr) is an eight-bit register that, together with the baud rate generator clock source selected by the cks1 and cks0 bits in the serial mode register (smr), determines the serial transmit/receive bit rate. the cpu can always read and write the brr. the brr is initialized to h'ff by a reset or in standby mode. sci1 and sci2 have independent baud rate generator control, so different values can be set in the two channels. bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w table 13.3 shows examples of brr settings in the asynchronous mode; table 13.4 shows examples of bbr settings in the clocked synchronous mode. table 13.3 bit rates and brr settings in asynchronous mode f (mhz) 2 2.097152 bit rate (bits/s) n n error (%) nn error (%) 110 1 141 0.03 1 148 ?.04 150 1 103 0.16 1 108 0.21 300 0 207 0.16 0 217 0.21 600 0 103 0.16 0 108 0.21 1200 0 51 0.16 0 54 ?.70 2400 0 25 0.16 0 26 1.14 4800 0 12 0.16 0 13 ?.48 9600 0 6 ?.48 19200 31250 0 1 0.00 38400
hitachi 356 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 2.4576 3 3.6864 bit rate(bits/s) n n error (%) n n error (%) n n error (%) 110 1 174 ?.26 1 212 0.03 2 64 0.70 150 1 127 0.00 1 155 0.16 1 191 0.00 300 0 255 0.00 1 77 0.16 1 95 0.00 600 0 127 0.00 0 155 0.16 0 191 0.00 1200 0 63 0.00 0 77 0.16 0 95 0.00 2400 0 31 0.00 0 38 0.16 0 47 0.00 4800 0 15 0.00 0 19 ?.34 0 23 0.00 9600 0 7 0.00 0 9 ?.34 0 11 0.00 19200 0 3 0.00 0 4 ?.34 0 5 0.00 31250 0 2 0.00 38400 0 1 0.00 0 2 0.00 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 4 4.9152 5 bit rate(bits/s) n n error (%) n n error (%) n n error (%) 110 2 70 0.03 2 86 0.31 2 88 ?.25 150 1 207 0.16 1 255 0.00 2 64 0.16 300 1 103 0.16 1 127 0.00 1 129 0.16 600 0 207 0.16 0 255 0.00 1 64 0.16 1200 0 103 0.16 0 127 0.00 0 129 0.16 2400 0 51 0.16 0 63 0.00 0 64 0.16 4800 0 25 0.16 0 31 0.00 0 32 ?.36 9600 0 12 0.16 0 15 0.00 0 15 1.73 19200 0 7 0.00 0 7 1.73 31250 0 3 0.00 0 4 ?.70 0 4 0.00 38400 0 3 0.00 0 3 1.73
hitachi 357 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 6 6.144 7.3728 bit rate(bits/s) n n error (%) n n error (%) n n error (%) 110 2 106 ?.44 2 108 0.08 2 130 ?.07 150 2 77 0.16 2 79 0.00 2 95 0.00 300 1 155 0.16 1 159 0.00 1 191 0.00 600 1 77 0.16 1 79 0.00 1 95 0.00 1200 0 155 0.16 0 159 0.00 0 191 0.00 2400 0 77 0.16 0 79 0.00 0 95 0.00 4800 0 38 0.16 0 39 0.00 0 47 0.00 9600 0 19 ?.34 0 19 0.00 0 23 0.00 19200 0 9 ?.34 0 9 0.00 0 11 0.00 31250 0 5 0.00 0 5 2.40 38400 0 4 ?.34 0 4 0.00 0 5 0.00 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 8 9.8304 10 12 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 141 0.03 2 174 ?.26 2 177 ?.25 2 212 0.03 150 2 103 0.16 2 127 0.00 2 129 0.16 2 155 0.16 300 1 207 0.16 1 255 0.00 2 64 0.16 2 77 0.16 600 1 103 0.16 1 127 0.00 1 129 0.16 1 155 0.16 1200 0 207 0.16 0 255 0.00 1 64 0.16 1 77 0.16 2400 0 103 0.16 0 127 0.00 0 129 0.16 0 155 0.16 4800 0 51 0.16 0 63 0.00 0 64 0.16 0 77 0.16 9600 0 25 0.16 0 31 0.00 0 32 ?.36 0 38 0.16 19200 0 12 0.16 0 15 0.00 0 15 1.73 0 19 ?.34 31250 0 7 0.00 0 9 ?.70 0 9 0.00 0 11 0.00 38400 0 7 0.00 0 7 1.73 0 9 ?.34
hitachi 358 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 12.288 14 14.7456 16 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 2 217 0.08 2 248 ?.17 3 64 0.70 3 70 0.03 150 2 159 0.00 2 181 0.16 2 191 0.00 2 207 0.16 300 2 79 0.00 2 90 0.16 2 95 0.00 2 103 0.16 600 1 159 0.00 1 181 0.16 1 191 0.00 1 207 0.16 1200 1 79 0.00 1 90 0.16 1 95 0.00 1 103 0.16 2400 0 159 0.00 0 181 0.16 0 191 0.00 0 207 0.16 4800 0 79 0.00 0 90 0.16 0 95 0.00 0 103 0.16 9600 0 39 0.00 0 45 ?.93 0 47 0.00 0 51 0.16 19200 0 19 0.00 0 22 ?.93 0 23 0.00 0 25 0.16 31250 0 11 2.40 0 13 0.00 0 14 ?.70 0 15 0.00 38400 0 9 0.00 0 11 0.00 0 12 0.16 table 13.3 bit rates and brr settings in asynchronous mode (cont) f (mhz) 17.2032 18 19.6608 20 bit rate (bits/s) n n error (%) n n error (%) n n error (%) n n error (%) 110 3 75 0.48 3 79 ?.12 3 86 0.31 3 88 ?.25 150 2 223 0.00 2 233 0.16 2 255 0.00 3 64 0.16 300 2 111 0.00 2 116 0.16 1 127 0.00 2 129 0.16 600 1 223 0.00 1 233 0.16 1 255 0.00 2 64 0.16 1200 1 111 0.00 1 116 0.16 0 127 0.00 1 129 0.16 2400 0 223 0.00 0 233 0.16 0 255 0.00 1 64 0.16 4800 0 111 0.00 0 116 0.16 0 127 0.00 0 129 0.16 9600 0 55 0.00 0 58 ?.69 0 63 0.00 0 64 0.16 19200 0 27 0.00 0 28 1.02 0 31 0.00 0 32 ?.36 31250 0 16 1.20 0 17 0.00 0 19 ?.70 0 19 0.00 38400 0 13 0.00 0 14 ?.34 0 15 0.00 0 15 1.73
hitachi 359 table 13.4 bit rates and brr settings in clocked synchronous mode f (mhz) bit rate 2 4 8 101620 (bits/s) n n n n n n n n n n n n 110 370 250 2 124 2 249 3 124 3 249 500 1 249 2 124 2 249 3 124 1k 1 124 1 249 2 124 2 249 2.5k 0 199 1 99 1 199 1 249 2 99 2 124 5k 0 99 0 199 1 99 1 124 1 199 1 249 10k 0 49 0 99 0 199 0 249 1 99 1 124 25k 0 19 0 39 0 79 0 99 0 159 0 199 50k 0 9 0 19 0 39 0 49 0 79 0 99 100k 0 4 0 9 0 19 0 24 0 39 0 49 250k 0 1 0 3 0 7 0 9 0 15 0 19 500k 0 0 ? 01 03 04 0 7 09 1m 0 0 * 01 0 3 04 2.5m 0 0 * 0 1 5m 0 0 * note settings with an error of 1% or less are recommended. blank: no setting available ? setting possible, but error occurs ? : continuous transmit/receive not possible the brr setting is calculated as follows: asynchronous mode n = [ f /(64 2 2n ?1 b)] 10 6 ?1 clocked synchronous mode n = [ f /(8 2 2n ?1 b)] 10 6 ?1 b: bit rate (bit/s) n: brr setting for baud rate generator (0 n 255) f : f frequency (mhz) n: baud rate generator clock source (n = 0, 1, 2, 3) for the clock sources and values of n, see table 13.5.
hitachi 360 smr settings n clock source cks1 cks0 0 f 00 1 f /4 0 1 2 f /16 1 0 3 f /24 1 1 find the bit rate error for the asynchronous mode by the following formula. error (%) = {( f 10 6 )/[(n + 1) b 64 22n ?1 ] ?1 } 100
hitachi 361 table 13.5 indicates the maximum bit rates in the asynchronous mode when the baud rate generator is being used. tables 13.6 and 13.7 show the maximum rates for external clock input. table 13.5 maximum bit rates for various frequencies with baud rate generator (asynchronous mode) settings f (mhz) maximum bit rate (bits/s) n n 2 62500 0 0 2.097152 65536 0 0 2.4576 76800 0 0 3 93750 0 0 3.6864 115200 0 0 4 125000 0 0 4.9152 153600 0 0 5 156250 0 0 6 187500 0 0 6.144 192000 0 0 7.3728 230400 0 0 8 250000 0 0 9.8304 307200 0 0 10 312500 0 0 12 375000 0 0 12.288 384000 0 0 14 437500 0 0 14.7456 460800 0 0 16 500000 0 0 17.2032 537600 0 0 18 562500 0 0 19.6608 614400 0 0 20 625000 0 0
hitachi 362 table 13.6 maximum bit rates during external clock input (asynchronous mode) f (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.5000 31250 2.097152 0.5243 32768 2.4576 0.6144 38400 3 0.7500 46875 3.6864 0.9216 57600 4 1.0000 62500 4.9152 1.2288 76800 5 1.2500 78125 6 1.5000 93750 6.144 1.5360 96000 7.3728 1.8432 115200 8 2.0000 125000 9.8304 2.4576 153600 10 2.5000 156250 12 3.0000 187500 12.288 3.0720 192000 14 3.5000 218750 14.7456 3.6834 230400 16 4.0000 250000 17.2032 4.3008 268800 18 4.5000 281250 19.6608 4.9152 307200 20 5.0000 312500
hitachi 363 table 13.7 maximum bit rates during external clock input (clocked synchronous mode) f (mhz) external input clock (mhz) maximum bit rate (bits/s) 2 0.3333 333333.3 4 0.6667 666666.7 6 1.0000 1000000.0 8 1.3333 1333333.3 10 1.6667 1666666.7 12 2.0000 2000000.0 14 2.3333 2333333.3 16 2.6667 2666666.7 18 3.0000 3000000.0 20 3.3333 3333333.3 13.3 operation 13.3.1 overview the sci has an asynchronous mode in which characters are synchronized individually, and a clocked synchronous mode in which communication is synchronized with clock pulses. serial communication is possible in either mode. asynchronous/clocked synchronous mode and the communication format are selected in the serial mode register (smr), as shown in table 13.8. the sci clock source is selected by the c/a bit in the serial mode register (smr) and the cke1 and cke0 bits in the serial control register (scr), as shown in table 13.9. asynchronous mode: data length is selectable: seven or eight bits. parity and multiprocessor bits are selectable. so is the stop bit length (one or two bits). the preceding selections constitute the communication format and character length. in receiving, it is possible to detect framing errors (fer), parity errors (per), overrun errors (orer), and the break state. an internal or external clock can be selected as the sci clock source. ? when an internal clock is selected, the sci operates using the on-chip baud rate generator, and can output a serial clock signal with a frequency matching the bit rate. ? when an external clock is selected, the external clock input must have a frequency 16 times the bit rate. (the on-chip baud rate generator is not used.)
hitachi 364 clocked synchronous mode: the communication format has a fixed eight-bit data length. in receiving, it is possible to detect overrun errors (orer). an internal or external clock can be selected as the sci clock source. ? when an internal clock is selected, the sci operates using the on-chip baud rate generator, and outputs a serial clock signal to external devices. ? when an external clock is selected, the sci operates on the input serial clock. the on-chip baud rate generator is not used. table 13.8 serial mode register settings and sci communication formats smr settings sci communication format mode bit 7: c/a bit 6: chr bit 5: pe bit 2: mp bit 3: stop data length parity bit multipro- cessor bit stop bit length asynchronous 0 0 0 0 0 8-bit absent absent 1 bit 1 2 bits 1 0 present 1 bit 1 2 bits 1 0 0 7-bit absent 1 bit 1 2 bits 1 0 present 1 bit 1 2 bits asynchronous 0 * 1 0 8-bit absent present 1 bit (multiprocessor * 1 2 bits format) 1 * 0 7-bit 1 bit * 1 2 bits clocked synchronous 1 * * * * 8-bit absent none note: asterisks (*) in the table indicate don?-care bits.
hitachi 365 table 13.9 smr and scr settings and sci clock source selection smr scr settings sci transmit/receive clock mode bit 7: c/ a bit 1: cke1 bit 0: cke0 clock source sck pin function* asynchronous 0 0 0 internal sci does not use the sck pin mode 1 outputs a clock with frequency matching the bit rate 1 0 external inputs a clock with frequency 16 times the bit rate 1 clocked synch- 1 0 0 internal outputs the serial clock ronous mode 1 1 0 external inputs the serial clock 1 note: select the function in combination with the pin function controller (pfc).
hitachi 366 13.3.2 operation in asynchronous mode in the asynchronous mode, each transmitted or received character begins with a start bit and ends with a stop bit. serial communication is synchronized one character at a time. the transmitting and receiving sections of the sci are independent, so full duplex communication is possible. the transmitter and receiver are both double buffered, so data can be written and read while transmitting and receiving are in progress, enabling continuous transmitting and receiving. figure 13.2 shows the general format of asynchronous serial communication. in asynchronous serial communication, the communication line is normally held in the mark (high) state. the sci monitors the line and starts serial communication when the line goes to the space (low) state, indicating a start bit. one serial character consists of a start bit (low), data (lsb first), parity bit (high or low), and stop bit (high), in that order. when receiving in the asynchronous mode, the sci synchronizes on the falling edge of the start bit. the sci samples each data bit on the eighth pulse of a clock with a frequency 16 times the bit rate. receive data is latched at the center of each bit. 0d 0 d 1 d 2 d 3 d 4 d 5 d 6 d 7 1 1 0/1 1 1 (lsb) (msb) serial data start bit 1 bit transmit/receive data 7 or 8 bits one unit of communication (characters or frames) idling (mark state) parity bit stop bit 1 or no bit 1 or 2 bits figure 13.2 data format in asynchronous communication (example: 8-bit data with parity and two stop bits)
hitachi 367 transmit/receive formats: table 13.10 shows the 12 communication formats that can be selected in the asynchronous mode. the format is selected by settings in the serial mode register (smr). table 13.10 serial communication formats (asynchronous mode) smr bits chr pe mp stop 1 2345678 9 10 11 12 0 0 0 0 start 8-bit data stop 0 0 0 1 start 8-bit data stop stop 0 1 0 0 start 8-bit data p stop 0 1 0 1 start 8-bit data p stop stop 1 0 0 0 start 7-bit data stop 1 0 0 1 start 7-bit data stop stop 1 1 0 0 start 7-bit data p stop 1 1 0 1 start 7-bit data p stop stop 0 1 0 start 8-bit data mpb stop 0 1 1 start 8-bit data mpb stop stop 1 1 0 start 7-bit data mpb stop 1 1 1 start 7-bit data mpb stop stop ? don't care bits. note: start: start bit stop: stop bit p: parity bit mpb: multiprocessor bit clock: an internal clock generated by the on-chip baud rate generator or an external clock input from the sck pin can be selected as the sci transmit/receive clock. the clock source is selected by the c/ a bit in the serial mode register (smr) and bits cke1 and cke0 in the serial control register (scr) (table 13.9). when an external clock is input at the sck pin, it must have a frequency equal to 16 times the
hitachi 368 desired bit rate. when the sci operates on an internal clock, it can output a clock signal at the sck pin. the frequency of this output clock is equal to the bit rate. the phase is aligned as in figure 13.3 so that the rising edge of the clock occurs at the center of each transmit data bit. 0 d0d1d2d3d4d5d6d70/1 1 1 1 frame figure 13.3 phase relationship between output clock and serial data (asynchronous mode) transmitting and receiving data (sci initialization (asynchronous mode)): before transmitting or receiving, software must clear the te and re bits to 0 in the serial control register (scr), then initialize the sci as follows. when changing the communication mode or format, always clear the te and re bits to 0 before following the procedure given below. clearing te to 0 sets tdre to 1 and initializes the transmit shift register (tsr). clearing re to 0, however, does not initialize the rdrf, per, fer, and orer flags and receive data register (rdr), which retain their previous contents. when an external clock is used, the clock should not be stopped during initialization or subsequent operation. sci operation becomes unreliable if the clock is stopped. figure 13.4 is a sample flowchart for initializing the sci. the procedure for initializing the sci is as follows: 1. select the communication format in the serial mode register (smr). 2. write the value corresponding to the bit rate in the bit rate register (brr) unless an external clock is used. 3. select the clock source in the serial control register (scr). leave rie, tie, teie, mpie, te and re cleared to 0. if clock output is selected in asynchronous mode, clock output starts immediately after the setting is made to scr. 4. wait for at least the interval required to transmit or receive one bit, then set te or re in the serial control register (scr) to 1. also set rie, tie, teie and mpie as necessary. setting te or re enables the sci to use the txd or rxd pin. the initial states are the mark transmit state, and the idle receive state (waiting for a start bit).
hitachi 369 start of initialization clear te and re bits to 0 in scr select communication format in smr set value in brr set cke1 and cke0 bits in scr (leaving te and re cleared to 0) wait set te or re to 1 in scr; set rie, tie, teie, and mpie as necessary 1-bit interval elapsed? end (1) (2) (3) (4) no yes note: circled numbers refer to the preceding procedure. figure 13.4 sample flowchart for sci initialization transmitting serial data (asynchronous mode): figure 13.5 shows a sample flowchart for transmitting serial data. the procedure for transmitting serial data is as follows: 1. sci initialization: select the txd pin function with the pfc. 2. sci status check and transmit data write: read the serial status register (ssr), check that the tdre bit is 1, then write transmit data in the transmit data register (tdr) and clear tdre to 0. 3. to continue transmitting serial data: read the tdre bit to check whether it is safe to write (1); if so, write data in tdr, then clear tdre to 0. when the dmac is started by a transmit-data- empty interrupt request (txi) to write data in tdr, the tdre bit is checked and cleared automatically. 4. to output a break signal at the end of serial transmission: set the dr bit to 0 (i/ o data port register), then clear te to 0 in scr and set the txd pin function as output port with the pfc.
hitachi 370 start transmitting initialize read tdre bit in ssr read tend bit in ssr clear te bit of scr to 0; select thetxd pin function as an output port with the pfc tend = 1? transmission ends (1) (2) (3) no yes tdre = 1? write transmit data in tdr and clear tdre bit to 0 in ssr all data transmitted? no yes output break signal? no yes set dr = 0 (4) yes no note: circled numbers refer to the preceding procedure. figure 13.5 sample flowchart for transmitting serial data
hitachi 371 in transmitting serial data, the sci operates as follows: 1. the sci monitors the tdre bit in the ssr. when tdre is cleared to 0, the sci recognizes that the transmit data register (tdr) contains new data, and loads this data from the tdr into the transmit shift register (tsr). 2. after loading the data from the tdr into the tsr, the sci sets the tdre bit to 1 and starts transmitting. if the transmit-data-empty interrupt enable bit (tie) is set to 1 in the scr, the sci requests a transmit-data-empty interrupt (txi) at this time. serial transmit data is transmitted in the following order from the txd pin: 1. start bit: one 0 bit is output. 2. transmit data: seven or eight bits of data are output, lsb first. 3. parity bit or multiprocessor bit: one parity bit (even or odd parity) or one multiprocessor bit is output. formats in which neither a parity bit nor a multiprocessor bit is output can also be selected. 4. stop bit: one or two 1 bits (stop bits) are output. 5. mark state: output of 1 bits continues until the start bit of the next transmit data. 6. the sci checks the tdre bit when it outputs the stop bit. if tdre is 0, the sci loads new data from the tdr into the tsr, outputs the stop bit, then begins serial transmission of the next frame. if tdre is 1, the sci sets the tend bit to 1 in the ssr, outputs the stop bit, then continues output of 1 bits in the mark state. if the transmit-end interrupt enable bit (teie) in the scr is set to 1, a transmit-end interrupt (tei) is requested. figure 13.6 shows an example of sci transmit operation in the asynchronous mode.
hitachi 372 01 1 1 0/1 0 1 tdre tend parity bit parity bit serial data start bit data stop bit start bit data stop bit idle (mark state) txi request txi interrupt handler writes data in tdr and clears tdre to 0 txi request tei request 1 frame d 0 d 1 d 7 d 0 d 1 d 7 0/1 figure 13.6 example of sci transmit operation in asynchronous mode (8-bit data with parity and one stop bit) receiving serial data (asynchronous mode): figure 13.7 shows a sample flowchart for receiving serial data. the procedure for receiving serial data is listed below. 1. sci initialization: select the rxd pin function with the pfc. 2. receive error handling and break detection: if a receive error occurs, read the orer, per and fer bits of the ssr to identify the error. after executing the necessary error handling, clear orer, per and fer all to 0. receiving cannot resume if orer, per or fer remains set to 1. when a framing error occurs, the rxd pin can be read to detect the break state. 3. sci status check and receive data read: read the serial status register (sr), check that rdrf is set to 1, then read receive data from the receive data register (rdr) and clear rdrf to 0. the rxi interrupt can also be used to determine if the rdrf bit has changed from 0 to 1. 4. to continue receiving serial data: read rdrf and rdr, and clear rdrf to 0 before the stop bit of the current frame is received. if the dmac is started by a receive-data-full interrupt (rxi) to read rdr, the rdrf bit is cleared automatically so this step is unnecessary.
hitachi 373 start receiving initialization read the orer, per, and fer bits of the ssr total count received? reception ends (1) no yes per, fer, orer = 1? rdrf = 1? yes yes clear the re bit of the scr to 0 no no read the rdrf bit of the ssr error handling (3) (2) read the rdr's receive data and clear the ssr's rdrf bit to 0 (4) note: circled numbers refer to the preceding procedure. figure 13.7 sample flowchart for receiving serial data
hitachi 374 start of error handling orer = 1? overrun error handling fer = 1? yes break? no framing error handling per = 1? yes parity error handling clear orer, per, and fer to 0 in ssr end clear re bit to 0 in scr no no no yes yes note: circled numbers refer to the preceding procedure. figure 13.7 sample flowchart for receiving serial data (cont)
hitachi 375 in receiving, the sci operates as follows: 1. the sci monitors the receive data line. when it detects a start bit (0), the sci synchronizes internally and starts receiving. 2. receive data is shifted into the rsr in order from the lsb to the msb. 3. the parity bit and stop bit are received. after receiving these bits, the sci makes the following checks: a. parity check: the number of 1s in the receive data must match the even or odd parity setting of the o/ e bit in the smr. b. stop bit check: the stop bit value must be 1. if there are two stop bits, only the first stop bit is checked. c. status check: rdrf must be 0 so that receive data can be loaded from the rsr into the rdr. if these checks all pass, the sci sets rdrf to 1 and stores the received data in the rdr. if one of the checks fails (receive error), the sci operates as indicated in table 13.11. note: when a receive error flag is set, further receiving is disabled. the rdrf bit is not set to 1. be sure to clear the error flags. 4. after setting rdrf to 1, if the receive-data-full interrupt enable bit (rie) is set to 1 in the scr, the sci requests a receive-data-full interrupt (rxi). if one of the error flags (orer, per, or fer) is set to 1 and the receive-data-full interrupt enable bit (rie) in the scr is also set to 1, the sci requests a receive-error interrupt (eri). figure 13.8 shows an example of sci receive operation in the asynchronous mode. table 13.11 receive error conditions and sci operation receive error abbreviation condition data transfer overrun error orer receiving of next data ends while rdrf is still set to 1 in ssr receive data not loaded from rsr into rdr framing error fer stop bit is 0 receive data loaded from rsr into rdr parity error per parity of receive data differs from even/odd parity setting in smr receive data loaded from rsr into rdr
hitachi 376 tdre fer framing error, eri request 1 frame rxi interrupt handler reads data in rdr and clears rdrf to 0 rxi request 01 1 1 0/1 0 0 parity bit parity bit serial data start bit data stop bit start bit data stop bit idle (mark state) d 0 d 1 d 7 d 0 d 1 d 7 0/1 figure 13.8 example of sci receive operation (8-bit data with parity and one stop bit) 13.3.3 multiprocessor communication the multiprocessor communication function enables several processors to share a single serial communication line. the processors communicate in the asynchronous mode using a format with an additional multiprocessor bit (multiprocessor format). in multiprocessor communication, each receiving processor is addressed by a unique id. a serial communication cycle consists of an id-sending cycle that identifies the receiving processor, and a data-sending cycle. the multiprocessor bit distinguishes id-sending cycles from data-sending cycles. the transmitting processor starts by sending the id of the receiving processor with which it wants to communicate as data with the multiprocessor bit set to 1. next the transmitting processor sends transmit data with the multiprocessor bit cleared to 0. receiving processors skip incoming data until they receive data with the multiprocessor bit set to 1. when they receive data with the multiprocessor bit set to 1, receiving processors compare the data with their ids. the receiving processor with a matching id continues to receive further incoming data. processors with ids not matching the received data skip further incoming data until they again receive data with the multiprocessor bit set to 1. multiple processors can send and receive data in this way. figure 13.9 shows the example of communication among processors using the multiprocessor format.
hitachi 377 receiving processor a (id = 01) (id = 02) (id = 03) (id = 04) receiving processor b receiving processor c serial communication line h'01 h'aa (mpb = 0) (mpb = 1) id-sending cycle: receiving processor address serial data transmitting processor receiving processor d data-sending cycle: data sent to receiving processor specified by id mpb: multiprocessor bit figure 13.9 example of communication among processors using multiprocessor format (sending data h'aa to receiving processor a) communication formats: four formats are available. parity-bit settings are ignored when the multiprocessor format is selected. for details see table 13.8. clock: see the description in the asynchronous mode section. transmitting multiprocessor serial data: figure 13.10 shows a sample flowchart for transmitting multiprocessor serial data. the procedure for transmitting multiprocessor serial data is listed below. 1. sci initialization: select the txd pin function with the pfc. 2. sci status check and transmit data write: read the serial status register (ssr), check that the tdre bit is 1, then write transmit data in the transmit data register (tdr). also set mpbt (multiprocessor bit transfer) to 0 or 1 in ssr. finally, clear tdre to 0. 3. to continue transmitting serial data: read the tdre bit to check whether it is safe to write (1); if so, write data in tdr, then clear tdre to 0. when the dmac is started by a transmit-data- empty interrupt request (txi) to write data in tdr, the tdre bit is checked and cleared automatically. 4. to output a break signal at the end of serial transmission: set the dr bit to 0 (i/o data port register), then clear te to 0 in scr and set the txd pin function as output port with the pfc.
hitachi 378 tdre = 1? write transmit data in tdr and set mpbt in ssr all data transmitted? yes tend = 1? read tend bit in ssr output break signal? yes set dr = 0 clear te bit to 0 in scr; select thetxd pin function as an output port with the pfc end yes read tdre bit in ssr clear tdre bit to 0 initialize no no yes no no (1) (2) (3) (4) start transmitting note: circled numbers refer to the preceding procedure. figure 13.10 sample flowchart for transmitting multiprocessor serial data in transmitting serial data, the sci operates as follows:
hitachi 379 1. the sci monitors the tdre bit in the ssr. when tdre is cleared to 0 the sci recognizes that the transmit data register (tdr) contains new data, and loads this data from the tdr into the transmit shift register (tsr). 2. after loading the data from the tdr into the tsr, the sci sets the tdre bit to 1 and starts transmitting. if the transmit-data-empty interrupt enable bit (tie) in the scr is set to 1, the sci requests a transmit-data-empty interrupt (txi) at this time. serial transmit data is transmitted in the following order from the txd pin (figure 13.11): 1. start bit: one 0 bit is output. 2. transmit data: seven or eight bits are output, lsb first. 3. multiprocessor bit: one multiprocessor bit (mpbt value) is output. 4. stop bit: one or two 1 bits (stop bits) are output. 5. mark state: output of 1 bits continues until the start bit of the next transmit data. 6. the sci checks the tdre bit when it outputs the stop bit. if tdre is 0, the sci loads data from the tdr into the tsr, outputs the stop bit, then begins serial transmission of the next frame. if tdre is 1, the sci sets the tend bit in the ssr to 1, outputs the stop bit, then continues output of 1 bits in the mark state. if the transmit-end interrupt enable bit (teie) in the scr is set to 1, a transmit-end interrupt (tei) is requested at this time. tdre tend txi request txi interrupt handler writes data in tdr and clears tdre to 0 txi request tei request 1 frame 01 1 1 0/1 0 1 multi- processor bit serial data start bit data stop bit start bit data stop bit idle (mark state) d 0 d 1 d 7 d 0 d 1 d 7 0/1 multi- processor bit figure 13.11 example of sci multiprocessor transmit operation (8-bit data with multiprocessor bit and one stop bit)
hitachi 380 receiving multiprocessor serial data: figure 13.12 shows a sample flowchart for receiving multiprocessor serial data. the procedure for receiving multiprocessor serial data is listed below. 1. sci initialization: select the rxd pin function with the pfc. 2. id receive cycle: set the mpie bit in the serial control register (scr) to 1. 3. sci status check and compare to id reception: read the serial status register (ssr), check that rdrf is set to 1, then read data from the receive data register (rdr) and compare with the processor's own id. if the id does not match the receive data, set mpie to 1 again and clear rdrf to 0. if the id matches the receive data, clear rdrf to 0. 4. receive error handling and break detection: if a receive error occurs, read the orer and fer bits in ssr to identify the error. after executing the necessary error handling, clear both orer and fer to 0. receiving cannot resume if orer or fer remain set to 1. when a framing error occurs, the rxd pin can be read to detect the break state. 5. sci status check and data receiving: read ssr, check that rdrf is set to 1, then read data from the receive data register (rdr).
hitachi 381 rdrf = 1? fer = 1? or orer = 1? rdrf = 1? total count received? no reception ends yes set the mpie bit of the scr to 1 read the ssr's rdrf bit initialization clear the re bit of the scr to 0 no no (1) (2) read the orer and fer bits of the ssr fer = 1? or orer = 1? read the rdrf bit of the ssr read the receive data of the rdr own id? yes read the orer and fer bits of the ssr (3) no error handling yes yes (4) yes no start receiving no yes read the rdr's receive data (5) figure 13.12 sample flowchart for receiving multiprocessor serial data
hitachi 382 orer = 1? break? yes framing error handling yes start of error handling overrun error handling yes fer = 1? clear orer and fer to 0 in ssr end no no no clear re bit to 0 in scr figure 13.12 sample flowchart for receiving multiprocessor serial data (cont)
hitachi 383 figure 13.13 shows an example of sci receive operation using a multiprocessor format. rdrf mpie rdr value id1 rxi request, (multiprocessor interrupt) mpie = 0 rxi interrupt handler reads data in rdr and clears rdrf to 0 not own id, so mpie is set to 1 again no rxi interrupt, rdr maintains state 01 1 1 10 1 mpb mpb serial data start bit data id1 stop bit start bit data 1 stop bit idle (mark state) d 0 d 1 d 7 d 0 d 1 d 7 0 mpb figure 13.13 example of sci receive operation (own id does not match data) (8-bit data with multiprocessor bit and one stop bit)
hitachi 384 rdrf mpie rdr value id1 rxi request, (multiprocessor interrupt) mpie = 0 rxi interrupt handler reads data in rdr and clears rdrf to 0 not own id, so mpie is set to 1 again no rxi interrupt, rdr maintains state 01 1 1 10 1 mpb mpb serial data start bit data id1 stop bit start bit data 1 stop bit idle (mark state) d 0 d 1 d 7 d 0 d 1 d 7 0 mpb figure 13.13 example of sci receive operation (own id matches data) (8-bit data with multiprocessor bit and one stop bit) (cont) 13.3.4 clocked synchronous operation in the clocked synchronous mode, the sci transmits and receives data in synchronization with clock pulses. this mode is suitable for high-speed serial communication. the sci transmitter and receiver share the same clock but are otherwise independent, so full duplex communication is possible. the transmitter and receiver are also double buffered, so continuous transmitting or receiving is possible by reading or writing data while transmitting or receiving is in progress. figure 13.14 shows the general format in clocked synchronous serial communication.
hitachi 385 bit 0 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 lsb msb serial clock serial data * * transfer direction one unit (character or frame) of serial data note: high except in continuous transmitting or receiving. figure 13.14 data format in clocked synchronous communication in clocked synchronous serial communication, each data bit is output on the communication line from one falling edge of the serial clock to the next. data are guaranteed valid at the rising edge of the serial clock. in each character, the serial data bits are transmitted in order from the lsb (first) to the msb (last). after output of the msb, the communication line remains in the state of the msb. in the clocked synchronous mode, the sci transmits or receives data by synchronizing with the falling edge of the serial clock. communication format: the data length is fixed at eight bits. no parity bit or multiprocessor bit can be added. clock: an internal clock generated by the on-chip baud rate generator or an external clock input from the sck pin can be selected as the sci transmit/receive clock. the clock source is selected by the c/ a bit in the serial mode register (smr) and bits cke1 and cke0 in the serial control register (scr). see table 13.6. when the sci operates on an internal clock, it outputs the clock signal at the sck pin. eight clock pulses are output per transmitted or received character. when the sci is not transmitting or receiving, the clock signal remains in the high state. figure 13.15 shows an example of sci transmit operation. in transmitting serial data, the sci operates as follows. 1. the sci monitors the tdre bit in the ssr. when tdre is cleared to 0 the sci recognizes that the transmit data register (tdr) contains new data, and loads this data from the tdr into the transmit shift register (tsr). 2. after loading the data from the tdr into the tsr, the sci sets the tdre bit to 1 and starts transmitting. if the transmit-data-empty interrupt enable bit (tie) in the scr is set to 1, the sci requests a transmit-data-empty interrupt (txi) at this time.
hitachi 386 if clock output is selected, the sci outputs eight serial clock pulses. if an external clock source is selected, the sci outputs data in synchronization with the input clock. data are output from the txd pin in order from the lsb (bit 0) to the msb (bit 7). 3. the sci checks the tdre bit when it outputs the msb (bit 7). if tdre is 0, the sci loads data from the tdr into the tsr, transmits the msb, then begins serial transmission of the next frame. if tdre is 1, the sci sets the tend bit in the ssr to 1, transmits the msb, then holds the transmit data pin (txd) in the msb state. if the transmit-end interrupt enable bit (teie) in the scr is set to 1, a transmit-end interrupt (tei) is requested at this time. 4. after the end of serial transmission, the sck pin is held in the high state. bit 0 bit 1 bit 7 bit 0 bit 1 bit 6 serial clock serial data transmit direction bit 7 txi interrupt handler writes data in tdr and clears tdre to 0 1 frame txi request txi request tdre tend lsb msb tei request figure 13.15 example of sci transmit operation transmitting and receiving data: sci initialization (clocked synchronous mode): before transmitting or receiving, software must clear the te and re bits to 0 in the serial control register (scr), then initialize the sci as follows. when changing the communication mode or format, always clear the te and re bits to 0 before following the procedure given below. clearing te to 0 sets tdre to 1 and initializes the transmit shift register (tsr). clearing re to 0, however, does not initialize the rdrf, per, fer, and orer flags and receive data register (rdr), which retain their previous contents. figure 13.16 is a sample flowchart for initializing the sci. the procedure for initializing the sci is listed below.
hitachi 387 1. select the communication format in the serial mode register (smr). 2. write the value corresponding to the bit rate in the bit rate register (brr) unless an external clock is used. 3. select the clock source in the serial control register (scr). leave rie, tie, teie, mpie, te and re cleared to 0. 4. wait for at least the interval required to transmit or receive one bit, then set te or re in the serial control register (scr) to 1. also set rie, tie, teie and mpie. setting the corresponding bit of the pin function controller, te and re enables the sci to use the txd or rxd pin. start of initialization clear te and re bits to 0 in scr (3) 1-bit interval elapsed? set te or re to 1 in scr; set rie, tie, teie, and mpie select communication format in smr yes no set value in brr set rie, tie, teie, mpie, cke1, and cke0 bits in scr (leaving te and re cleared to 0) end wait (1) (2) (4) note: high except in continuous transmitting or receiving. figure 13.16 sample flowchart for sci initialization
hitachi 388 transmitting serial data (clocked synchronous mode): figure 13.17 shows a sample flowchart for transmitting serial data. the procedure for transmitting serial data is listed below. 1. sci initialization: select the txd pin function with the pfc. 2. sci status check and transmit data write: read the serial status register (ssr), check that the tdre bit is 1, then write transmit data in the transmit data register (tdr) and clear tdre to 0. the rxi interrupt can also be used to determine if the rdrf bit has changed from 0 to 1. 3. to continue transmitting serial data: read the tdre bit to check whether it is safe to write (1); if so, write data in tdr, then clear tdre to 0. when the dmac is started by a transmit-data- empty interrupt request (txi) to write data in tdr, the tdre bit is checked and cleared automatically.
hitachi 389 start transmitting read tdre bit in ssr all data transmitted? yes no transmission ends (1) initialize tdre = 1? write transmit data in tdr and clear tdre bit to 0 in ssr yes no read tend bit in ssr tend = 1? yes no clear te bit scr to 0 (2) (3) figure 13.17 sample flowchart for serial transmitting receiving serial data (clocked synchronous mode): figure 13.18 shows a sample flowchart for receiving serial data. when switching from the asynchronous mode to the clocked synchronous mode, make sure that orer, per, and fer are cleared to 0. if per or fer is set to 1, the rdrf bit will not be set and both transmitting and receiving will be disabled. figure 13.19 shows an example of sci recieve operation. the procedure for recieving serial data is listed below. 1. sci initialization: select the rxd pin function with the pfc. 2. receive error handling: if a receive error occurs, read the orer bit in ssr to identify the error. after executing the necessary error handling, clear orer to 0. transmitting/receiving
hitachi 390 cannot resume if orer remains set to 1. 3. sci status check and receive data read: read the serial status register (ssr), check that rdrf is set to 1, then read receive data from the receive data register (rdr) and clear rdrf to 0. the rxi interrupt can also be used to determine if the rdrf bit has changed from 0 to 1. 4. to continue receiving serial data: read rdr, and clear rdrf to 0 before the frame msb (bit 7) of the current frame is received. if the dmac is started by a receive-data-full interrupt (rxi) to read rdr, the rdrf bit is cleared automatically so this step is unnecessary. start receiving initialization read the orer bit of the ssr total count received? reception ends (1) no yes orer = 1? rdrf = 1? yes clear the re bit of the scr to 0 no no read rdrf bit of the ssr (3) yes error handling (2) read the rdr's receive data and clear the ssr's rdrf bit to 0 (4) figure 13.18 sample flowchart for serial receiving
hitachi 391 error handling end orer = 1? no clear orer bit of ssr to 0 yes overrun error handling figure 13.18 sample flowchart for serial receiving (cont) bit 7 bit 0 bit 7 bit 0 bit 1 bit 6 serial clock serial data receive direction bit 7 rxi interrupt handler reads data in rdr and clears rdrf to 0 1 frame rxi request rxi request overrun error, eri request rdrf orer figure 13.19 example of sci receive operation in receiving, the sci operates as follows: 1. the sci synchronizes with serial clock input or output and initializes internally. 2. receive data is shifted into the rsr in order from the lsb to the msb. after receiving the data, the sci checks that rdrf is 0 so that receive data can be loaded from the rsr into the
hitachi 392 rdr. if this check passes, the sci sets rdrf to 1 and stores the received data in the rdr. if the check does not pass (receive error), the sci operates as indicated in table 13.8. when the error flag is set to 1 and the rdrf bit is cleared to 0, the rdrf bit will not be set to 1 during reception. when restarting the reception, make sure to clear the error flag to 0. 3. after setting rdrf to 1, if the receive-data-full interrupt enable bit (rie) is set to 1 in the scr, the sci requests a receive-data-full interrupt (rxi). if the orer bit is set to 1 and the receive-data-full interrupt enable bit (rie) in the scr is also set to 1, the sci requests a receive-error interrupt (eri). transmitting and receiving serial data simultaneously (clocked synchronous mode): figure 13.20 shows a sample flowchart for transmitting and receiving serial data simultaneously. the procedure for transmitting and receiving serial data simultaneously is listed below. 1. sci initialization: select the txd and rxd pin function with the pfc. 2. sci status check and transmit data write: read the serial status register (ssr), check that the tdre bit is 1, then write transmit data in the transmit data register (tdr) and clear tdre to 0. the txi interrupt can also be used to determine if the tdre bit has changed from 0 to 1. 3. receive error handling: if a receive error occurs, read the orer bit in ssr to identify the error. after executing the necessary error handling, clear orer to 0. transmitting/receiving cannot resume if orer remains set to 1. 4. sci status check and receive data read: read the serial status register (ssr), check that rdrf is set to 1, then read receive data from the receive data register (rdr) and clear rdrf to 0. the rxi interrupt can also be used to determine if the rdrf bit has changed from 0 to 1. 5. to continue transmitting and receiving serial data: read the rdrf bit and rdr, and clear rdrf to 0 before the frame msb (bit 7) of the current frame is received. also read the tdre bit to check whether it is safe to write (1); if so, write data in tdr, then clear tdre to 0 before the msb (bit 7) of the current frame is transmitted. when the dmac is started by a transmit-data-empty interrupt request (txi) to write data in tdr, the tdre bit is checked and cleared automatically. when the dmac is started by a receive-data-full interrupt (rxi) to read rdr, the rdrf bit is cleared automatically.
hitachi 393 start transmitting and receiving initialization read tdre bit of the ssr total count transmitted and received? transmitting/receiving ends (1) (2) no yes tdre = 1? write transmit data to the tdr and clear the tdre bit of the ssr to 0 rdrf = 1? no yes yes no read the orer bit of the ssr error handling (3) orer = 1? no read the ssr's rdrf bit (5) yes (4) read the receive data of the rdr and clear the rdrf bit of the ssr to 0 clear the te and re bits of the scr to 0 note: in switching from transmitting or receiving to simultaneous transmitting and receiving, clear both te and re to 0, then set both te and re to 1. figure 13.20 sample flowchart for serial transmitting
hitachi 394 13.4 sci interrupt sources and the dmac the sci has four interrupt sources in each channel: transmit-end (tei), receive-error (eri), receive-data-full (rxi), and transmit-data-empty (txi). table 13.12 lists the interrupt sources and indicates their priority. these interrupts can be enabled and disabled by the tie, rie, and teie bits in the serial control register (scr). each interrupt request is sent separately to the interrupt controller. txi is requested when the tdre bit in the ssr is set to 1. txi can start the direct memory access controller (dmac) to transfer data. tdre is automatically cleared to 0 when the dmac executes the data transfer to the transmit data register (tdr). rxi is requested when the rdrf bit in the ssr is set to 1. rxi can start the dmac to transfer data. rdrf is automatically cleared to 0 when the dmac executes the data transfer to the receive data register (rdr). eri is requested when the orer, per, or fer bit in the ssr is set to 1. eri cannot start the dmac. tei is requested when the tend bit in the ssr is set to 1. tei cannot start the dmac. a txi interrupt indicates that transmit data writing is enabled. a tei interrupt indicates that the transmit operation is complete. table 13.12 sci interrupt sources interrupt source description dmac availability priority eri receive error (orer, per, or fer) no high rxi receive data full (rdrf) yes - txi transmit data empty (tdre) yes tend transmit end (tend) no low 13.5 usage notes note the following points when using the sci. tdr write and tdre flags: the tdre bit in the serial status register (ssr) is a status flag indicating loading of transmit data from the tdr into the tsr. the sci sets tdre to 1 when it transfers data from the tdr to the tsr. if new data is written in the tdr when tdre is 0, the old data stored in the tdr will be lost because these data have not yet been transferred to the tsr. before writing transmit data to the tdr, be sure to check that tdre is set to 1. simultaneous multiple receive errors: table 13.13 indicates the state of the ssr status flags when multiple receive errors occur simultaneously. when an overrun error occurs, the rsr contents cannot be transferred to the rdr, so receive data is lost.
hitachi 395 table 13.13 ssr status flags and transfer of receive data ssr status flags receive data transfer receive error status rdrf orer fer per rsr ? rdr overrun error 1 1 0 0 x framing error 0 0 1 0 o parity error 0 0 0 1 o overrun error + framing error 1 1 1 0 x overrun error + parity error 1 1 0 1 x framing error + parity error 0 0 1 1 o overrun error + framing error + parity error 1111x o: receive data is transferred from rsr?dr. x: receive data is not transferred from rsr?dr. break detection and processing: break signals can be detected by reading the rxd pin directly when a framing error (fer) is detected. in the break state, the input from the rxd pin consists of all 0s, so fer is set and the parity error flag (per) may also be set. in the break state, the sci receiver continues to operate, so if the fer bit is cleared to 0, it will be set to 1 again. sending a break signal: when te is cleared to 0 the txd pin becomes an i/o port, the level and direction (input or output) of which are determined by the data register (dr) of the i/o port and the control register (cr) of the pfc. this feature can be used to send a break signal. the dr value substitutes for the mark state until the pfc setting is performed. the dr bits should therefore be set as an output port that outputs 1 beforehand. to send a break signal during serial transmission, clear the dr bit to 0, and select output port as the txd pin function by the pfc. when te is cleared to 0, the transmitter is initialized, regardless of its current state. receive error flags and transmitter operation (clocked synchronous mode only): when a receive error flag (orer, per, or fer) is set to 1, the sci will not start transmitting even if tdre is set to 1. be sure to clear the receive error flags to 0 before starting to transmit. note that clearing re to 0 does not clear the receive error flags. receive data sampling timing and receive margin in the asynchronous mode: in the asynchronous mode, the sci operates on a base clock of 16 times the bit rate frequency. in receiving, the sci synchronizes internally with the falling edge of the start bit, which it samples on the base clock. receive data is latched on the rising edge of the eighth base clock pulse. see figure 13.21.
hitachi 396 0 1 2 3 4 5 6 7 8 9 10111213 1415 0 1 2 3 4 5 6 7 8 9 10111213 1415 0 1 2 3 4 5 internal base clock receive data (rxd) synchronization sampling timing data sampling timing 8 clocks 16 clocks start bit ?.5 clocks +7.5 clocks d0 d1 figure 13.21 receive data sampling timing in asynchronous mode the receive margin in the asynchronous mode can therefore be expressed as in equation 1. equation 1: m = 0.5 ? ? ( l ? 0.5) f ? (1 + f ) 100% 1 2 n d 0.5 n m: receive margin (%) n: ratio of clock frequency to bit rate (n = 16) d: clock duty cycle (d = 0?.0) l: frame length (l = 9?2) f: absolute deviation of clock frequency from equation (1), if f = 0 and d = 0.5 the receive margin is 46.875%, as given by equation 2. equation 2: d = 0.5, f = 0 m = (0.5 ?1/(2 16)) 100% = 46.875% (2) this is a theoretical value. a reasonable margin to allow in system designs is 20?0%. constraints on dmac use:
hitachi 397 when using an external clock source for the serial clock, update the tdr with the dmac, and then after five system clocks or more elapse, input a transmit clock. if a transmit clock is input in the first four system clocks after the tdr is written, an error may occur (figure 13.22). before reading the receive data register (rdr) with the dmac, select the receive-data-full interrupt of the sci as a start-up source using the resource select bit (rs) in the channel control register (chcr). d0 d1 d2 d3 d4 d5 d6 d7 sck tdre t note: during external clock operation, an error may occur if t is 4 f or less. figure 13.22 clocked synchronous transmitting example with dmac cautions for clocked synchronous external clock mode: set te = re = 1 only when the external clock sci is 1. do not set te = re = 1 until at least 4 clocks after the external clock sck has changed from 0 to 1. when receiving, rdrf = 1 when re is set to zero 2.5?.5 clocks after the rise edge of the rxd d7 bit sck input, but it cannot be copied to rdr. caution for clocked synchronous internal clock mode: when receiving, rdrf = 1 when re is set to zero 1.5 clocks after the rise edge of the rxd d7 bit sck input, but it cannot be copied to rdr.
hitachi 399 section 14 pin function controller (pfc) 14.1 overview the pin function controller (pfc) is composed of registers for selecting the function of multiplexed pins and the direction of input/output. the pin function and input/output direction can be selected for each pin individually without regard to the operating mode of the lsi. table 14.1 lists the multiplexed pins. table 14.1 list of multiplexed pins port function 1 (related module) function 2 (related module) function 3 (related module) function 4 (related module) pin # a pa15 i/o (port) irq3 input (intc) dreq1 input (dmac) ?8 a pa14 i/o (port) irq2 input (intc) dack1 output (dmac) ?7 a pa13 i/o (port) irq1 input (intc) tclkb input (itu) dreq0 input (dmac) 66 a pa12 i/o (port) irq0 input (intc) tclka input (itu) dack0 output (dmac) 65 a pa11 i/o (port) dph i/o (d bus) tiocb1 i/o (itu) 64 a pa10 i/o (port) dpl i/o (d bus) tioca1 i/o (itu) 62 a pa9 i/o (port) ah output (bsc) irqout output (intc) 61 a pa8 i/o (port) breq input (system) 60 a pa7 i/o (port) back output (system) 58 a pa6 i/o (port) rd output (bsc) 57 a pa5 i/o (port) wrh output (bsc) ( lbs output (bsc))* 1 56 a pa4 i/o (port) wrl output (bsc) ( wr output (bsc))* 1 55 a pa3 i/o (port) cs7 output (bsc) wait input (bsc) 54 a pa2 i/o (port) cs6 output (bsc) tiocb0 i/o (itu) 53 a pa1 i/o (port) cs5 output (bsc) ras output (bsc) 52 a pa0 i/o (port) cs4 output (bsc) tioca0 i/o (itu) 51
hitachi 400 table 14.1 list of multiplexed pins (cont) port function 1 (related module) function 2 (related module) function 3 (related module) function 4 (related module) pin # b pb15 i/o (port) irq7 input (intc) tp15 output (tpc) 100 b pb14 i/o (port) irq6 input (intc) tp14 output (tpc) 99 b pb13 i/o (port) irq5 input (intc) sck1 i/o (sci) tp13 output (tpc) 98 b pb12 i/o (port) irq4 input (intc) sck0 i/o (sci) tp12 output (tpc) 97 b pb11 i/o (port) txd1 output (sci) tp11 output (tpc) 96 b pb10 i/o (port) rxd1 input (sci) tp10 output (tpc) 95 b pb9 i/o (port) txd0 output (sci) tp9 output (tpc) 94 b pb8 i/o (port) rxd0 input (sci) tp8 output (tpc) 93 b pb7 i/o (port) tclkd input (itu) tocxb4 output (itu) tp7 output (tpc) 91 b pb6 i/o (port) tclkc input (itu) tocxa4 output (itu) tp6 output (tpc) 90 b pb5 i/o (port) tiocb4 i/o (itu) tp5 output (tpc) 89 b pb4 i/o (port) tioca4 i/o (itu) tp4 output (tpc) 87 b pb3 i/o (port) tiocb3 i/o (itu) tp3 output (tpc) 86 b pb2 i/o (port) tioca3 i/o (itu) tp2 output (tpc) 85 b pb1 i/o (port) tiocb2 i/o (itu) tp1 output (tpc) 84 b pb0 i/o (port) tioca2 i/o (itu) tp0 output (tpc) 83 cs1 output (bsc) cash output (bsc) 47 cs3 output (bsc) casl output (bsc) 49 intc: interrupt controller dmac: direct memory access controller itu: 16-bit integrated timer pulse unit d bus: data bus control bsc: bus state controller system: system control sci: serial communications interface tpc: programmable timing pattern controller port: i/o port notes: 1. the bus control register of the bus state controller handles switching between the two functions.
hitachi 401 14.2 register configuration table 14.2 summarizes the registers of the pin function controller. table 14.2 pin function controller registers name abbreviation r/w initial value address access size port a i/o register paior r/w h'0000 h'5ffffc4 8, 16, 32 port a control register 1 pacr1 r/w h'3302 h'5ffffc8 8, 16, 32 port a control register 2 pacr2 r/w h'ff95 h'5ffffca 8, 16, 32 port b i/o register pbior r/w h'0000 h'5ffffc6 8, 16, 32 port b control register 1 pbcr1 r/w h'0000 h'5ffffcc 8, 16, 32 port b control register 2 pbcr2 r/w h'0000 h'5ffffce 8, 16, 32 column address strobe pin control register cascr r/w h'5fff h'5ffffee 8, 16, 32 14.3 register descriptions 14.3.1 port a i/o register (paior) the port a i/o register (paior) is a 16-bit read/write register that selects input or output for individual pins on a bit-by-bit basis. bits pa15ior?a0ior correspond to pins pa15/ irq3 / dreq1 epa0/ cs4 /tioca0. paior is enabled when the port a pins function as input/outputs (pa15epa0) and for itu input capture and output compare (tioca1, tioca0, tiocb1, and tiocb0). for other functions, they are disabled. for port a pin functions pa15e pa0 and tioca1, tioca0, tiocb1, and tiocb0, a given pin in port a is an output pin if its corresponding paior bit is set to 1, and an input pin if the bit is cleared to 0. paior is initialized to h'0000 by power-on resets; however, it is not initialized for manual resets, standby mode, or sleep mode.
hitachi 402 bit: 15 14 13 12 11 10 9 8 bit name: pa15 ior pa14 ior pa13 ior pa12 ior pa11 ior pa10 ior pa9 ior pa8 ior initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pa7 ior pa6 ior pa5 ior pa4 ior pa3 ior pa2 ior pa1 ior pa0 ior initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w 14.3.2 port a control registers (pacr1 and pacr2) pacr1 and pacr2 are 16-bit read/write registers that select the functions of the sixteen multiplexed pins of port a. pacr1 selects the function of the top eight bits of port a; pacr2 selects the function of the bottom eight bits of port a. pacr1 and pacr2 are initialized to h'3302 and h'ff95 respectively by power-on resets but are not initialized for manual resets, standby mode, or sleep mode. pacr1: bit: 15 14 13 12 11 10 9 8 bit name: pa15 md1 pa15 md0 pa14 md1 pa14 md0 pa13 md1 pa13 md0 pa12 md1 pa12 md0 initial value: 0 0 1 1 0 0 1 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pa11 md1 pa11 md0 pa10 md1 pa10 md0 pa9md1 pa9md0 pa8md initial value: 0 0 0 0 0 0 1 0 r/w: r/w r/w r/w r/w r/w r/w r/w bits 15 and 14 (pa15 mode (pa15md1 and pa15md0)): pa15md1 and pa15md0 select the function of the pa15/ irq3 / dreq1 pin.
hitachi 403 bit 15: pa15md1 bit 14: pa15md0 function 0 0 input/output (pa15) (initial value) 1 interrupt request input ( irq3 ) 1 0 reserved 1 dma transfer request input ( dreq1 ) bits 13 and 12 (pa14 mode (pa14md1 and pa14md0)): pa14md1 and pa14md0 select the function of the pa14/ irq2 /dack1 pin. bit 13: pa14md1 bit 12: pa14md0 function 0 0 input/output (pa14) 1 interrupt request input ( irq2 ) 1 0 reserved 1 dma transfer acknowledge output (dack1) (initial value) bits 11 and 10 (pa13 mode (pa13md1 and pa13md0)): pa13md1 and pa13md0 select the function of the pa13/ irq1 / dreq0 /tclkb pin. bit 11: pa13md1 bit 10: pa13md0 function 0 0 input/output (pa13) (initial value) 1 interrupt request input ( irq1 ) 1 0 itu timer clock input (tclkb) 1 dma transfer request input ( dreq0 ) bits 9 and 8 (pa12 mode (pa12md1 and pa12md0)): these bits select the function of the pa12/ irq0 /dack0/tclka pin. bit 9: pa12md1 bit 8: pa12md0 function 0 0 input/output (pa12) 1 interrupt request input ( irq0 ) 1 0 itu timer clock input (tclka) 1 dma transfer acknowledge output (dack0) (initial value)
hitachi 404 bits 7 and 6 (pa11 mode (pa11md1 and pa11md0)): these bits select the function of the pa11/dph/tiocb1 pin. bit 7: pa11md1 bit 6: pa11md0 function 0 0 input/output (pa11) (initial value) 1 upper data bus parity input/output (dph) 1 0 itu input capture/output compare (tiocb1) 1 reserved bits 5 and 4 (pa10 mode (pa10md1 and pa10md0)): these bits select the function of the pa10/dpl/tioca1 pin. bit 5: pa10md1 bit 4: pa10md0 function 0 0 input/output (pa10) (initial value) 1 lower data bus parity input/output (dpl) 1 0 itu input capture/output compare (tioca1) 1 reserved bits 3 and 2 (pa9 mode (pa9md1 and pa9md0)): these bits select the function of the pa9/ ah / irqout pin. bit 3: pa9md1 bit 2: pa9md0 function 0 0 input/output (pa9) (initial value) 1 address hold output ( ah ) 1 0 reserved 1 interrupt request output ( irqout ) bit 1 (reserved): this bit always reads as 1. the write value should always be 1. bit 0 (pa8 mode (pa8md)): pa8md selects the function of the pa8/ breq . bit 0: pa8md function 0 input/output (pa8) (initial value) 1 bus request input ( breq )
hitachi 405 pacr2: bit: 15 14 13 12 11 10 9 8 bit name: pa7md pa6md pa5md pa4md initial value: 1 1 1 1 1 1 1 1 r/w: r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pa3md1 pa3md0 pa2md1 pa2md0 pa1md1 pa1md0 pa0md1 pa0md0 initial value: 1 0 0 1 0 1 0 1 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit 15 (reserved): this bit always reads as 1. the write value should always be 1. bit 14 (pa7 mode (pa7md)): pa7md selects the function of the pa7/ back pin. bit 14: pa7md function 0 input/output (pa7) 1 bus request acknowledge output ( back ) (initial value) bit 13 (reserved): this bit always reads as 1. the write value should always be 1. bit 12 (pa6 mode (pa6md)): pa6md selects the function of the pa6/ rd pin. bit 12: pa6md function 0 input/output (pa6) 1 read output ( rd ) (initial value) bit 11 (reserved): this bit always reads as 1. the write value should always be 1. bit 10 (pa5 mode (pa5md)): pa5md selects the function of the pa5/ wrh ( lbs ) pin. bit 10: pa5md function 0 input/output (pa5) 1 upper write output ( wrh ) or lower byte strobe output ( lbs ) (initial value) bit 9 (reserved): this bit always reads as 1. the write value should always be 1.
hitachi 406 bit 8 (pa4 mode (pa4md)): pa4md selects the function of the pa4/ wrl ( wr ) pin. bit 8: pa4md function 0 input/output (pa4) 1 lower write output ( wrl ) or write output ( wr ) (initial value) bits 7 and 6 (pa3 mode (pa3md1 and pa3md0)): pa3md1 and pa3md0 select the function of the pa3/ cs7 / wait pin. this pin has a pull-up mos that is used when it functions as a wait pin to allow selection of pull up or no pull up (for the wait pin) using the wait state control register of the bus state controller (bsc). there is no pull up when if functions as pa3 or cs7. bit 7: pa3md1 bit 6: pa3md0 function 0 0 input/output (pa3) 1 chip select output ( cs7 ) 1 0 wait state input ( wait ) (initial value) 1 reserved bits 5 and 4 (pa2 mode (pa2md1 and pa2md0)): pa2md1 and pa2md0 select the function of the pa2/ cs6 /tiocb0 pin. bit 5: pa2md1 bit 4: pa2md0 function 0 0 input/output (pa2) 1 chip select output ( cs6 ) (initial value) 1 0 itu input capture/output compare (tiocb0) 1 reserved bits 3 and 2 (pa1 mode (pa1md1 and pa1md0)): pa1md1 and pa1md0 select the function of the pa1/ cs5 / ras pin. bit 3: pa1md1 bit 2: pa1md0 function 0 0 input/output (pa1) 1 chip select output ( cs5 ) (initial value) 1 0 row address strobe output ( ras ) 1 reserved
hitachi 407 bits 1 and 0 (pa0 mode (pa0md1 and pa0md0)): pa0md1 and pa0md0 select the function of the pa0/ cs4 /tioca0 pin. bit 1: pa0md1 bit 0: pa0md0 function 0 0 input/output (pa0) 1 chip select output ( cs4 ) (initial value) 1 0 itu input capture/output compare (tioca0) 1 reserved 14.3.3 port b i/o register (pbior) the port b i/o register (pbior) is a 16-bit read/write register that selects input or output for individual pins on a bit-by-bit basis. bits pb15ior?b0ior correspond to pins of port b. pbior is enabled when the port b pins function as input/outputs (pb15?b0), for itu input capture and output compare (tioca4, tioca3, tioca2, tiocb4, tiocb3, and tiocb2), and as serial clocks (sck1, sck0). for other functions, they are disabled. for port b pin functions pb15?b0, and tioca4, tioca3, tioca2, tiocb4, tiocb3, and tiocb2, and sck1/sck0, a given pin in port b is an output pin if its corresponding pbior bit is set to 1, and an input pin if the bit is cleared to 0. pbior is initialized to h'0000 by power-on resets; however, it is not initialized for manual resets, standby mode, or sleep mode. bit: 15 14 13 12 11 10 9 8 bit name: pb15 ior pb14 ior pb13 ior pb12 ior pb11 ior pb10 ior pb9 ior pb8 ior initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb7 ior pb6 ior pb5 ior pb4 ior pb3 ior pb2 ior pb1 ior pb0 ior initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w
hitachi 408 14.3.4 port b control registers (pbcr1 and pbcr2) pbcr1 and pbcr2 are 16-bit read/write registers that select the functions of the sixteen multiplexed pins of port b. pbcr1 selects the function of the top eight bits of port b; pbcr2 selects the function of the bottom eight bits of port b. pbcr1 and pbcr2 are initialized to h'0000 by power-on resets but are not initialized for manual resets, standby mode, or sleep mode. pbcr1: bit: 15 14 13 12 11 10 9 8 bit name: pb15 md1 pb15 md0 pb14 md1 pb14 md0 pb13 md1 pb13 md0 pb12 md1 pb12 md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb11 md1 pb11 md0 pb10 md1 pb10 md0 pb9 md1 pb9 md0 pb8 md1 pb8 md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bits 15 and 14 (pb15 mode (pb15md1 and pb15md0)): pb15md1 and pb15md0 select the function of the pb15/tp15/ irq7 pin. bit 15: pb15md1 bit 14: pb15md0 function 0 0 input/output (pb15) (initial value) 1 interrupt request input ( irq7 ) 1 0 reserved 1 timing pattern output (tp15) bits 13 and 12 (pb14 mode (pb14md1 and pb14md0)): pb14md1 and pb14md0 select the function of the pb14/tp14/ irq6 pin. bit 13: pb14md1 bit 12: pb14md0 function 0 0 input/output (pb14) (initial value) 1 interrupt request input ( irq6 ) 1 0 reserved 1 timing pattern output (tp14)
hitachi 409 bits 11 and 10 (pb13 mode (pb13md1 and pb13md0)): pb13md1 and pb13md0 select the function of the pb13/tp13/ irq5 /sck1 pin. bit 11: pb13md1 bit 10: pb13md0 function 0 0 input/output (pb13) (initial value) 1 interrupt request input ( irq5 ) 1 0 serial clock input/output (sck1) 1 timing pattern output (tp13) bits 9 and 8 (pb12 mode (pb12md1 and pb12md0)): pb12md1 and pb12md0 select the function of the pb12/tp12/ irq4 /sck0 pin. bit 9: pb12md1 bit 8: pb12md0 function 0 0 input/output (pb12) (initial value) 1 interrupt request input ( irq4 ) 1 0 serial clock input/output (sck0) 1 timing pattern output (tp12) bits 7 and 6: pb11 mode (pb11md1 and pb11md0): pb11md1 and pb11md0 select the function of the pb11/tp11/txd1 pin. bit 7: pb11md1 bit 6: pb11md0 function 0 0 input/output (pb11) (initial value) 1 reserved 1 0 transmit data output (txd1) 1 timing pattern output (tp11) bits 5 and 4 (pb10 mode (pb10md1 and pb10md0): pb10md1 and pb10md0 select the function of the pb10/tp10/rxd1 pin. bit 5: pb10md1 bit 4: pb10md0 function 0 0 input/output (pb10) (initial value) 1 reserved 1 0 receive data input (rxd1) 1 timing pattern output (tp10)
hitachi 410 bits 3 and 2 (pb9 mode (pb9md1 and pb9md0)): pb9md1 and pb9md0 select the function of the pb9/tp9/txd0 pin. bit 3: pb9md1 bit 2: pb9md0 function 0 0 input/output (pb9) (initial value) 1 reserved 1 0 transmit data output (txd0) 1 timing pattern output (tp9) bits 1 and 0 (pb8 mode (pb8md1 and pb8md0)): pb8md1 and pb8md0 select the function of the pb8/tp8/rxd0 pin. bit 1: pb8md1 bit 0: pb8md0 function 0 0 input/output (pb8) (initial value) 1 reserved 1 0 receive data input (rxd0) 1 timing pattern output (tp8) pbcr2: bit: 15 14 13 12 11 10 9 8 bit name: pb7md1 pb7md0 pb6md1 pb6md0 pb5md1 pb5md0 pb4md1 pb4md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb3md1 pb3md0 pb2md1 pb2md0 pb1md1 pb1md0 pb0md1 pb0md0 initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w
hitachi 411 bits 15 and 14 (pb7 mode (pb7md1 and pb7md0)): pb7md1 and pb7md0 select the function of the pb7/tp7/tocxb4/tclkd pin. bit 15: pb7md1 bit 14: pb7md0 function 0 0 input/output (pb7) (initial value) 1 itu timer clock input (tclkd) 1 0 itu output compare (tocxb4) 1 timing pattern output (tp7) bits 13 and 12 (pb6 mode (pb6md1 and pb6md0)): pb6md1 and pb6md0 select the function of the pb6/tp6/tocxa4/tclkc pin. bit 13: pb6md1 bit 12: pb6md0 function 0 0 input/output (pb6) (initial value) 1 itu timer clock input (tclkc) 1 0 itu output compare (tocxa4) 1 timing pattern output (tp6) bits 11 and 10 (pb5 mode (pb5md1 and pb5md0)): pb5md1 and pb5md0 select the function of the pb5/tp5/tiocb4 pin. bit 11: pb5md1 bit 10: pb5md0 function 0 0 input/output (pb5) (initial value) 1 reserved 1 0 itu input capture/output compare (tiocb4) 1 timing pattern output (tp5) bits 9 and 8 (pb4 mode (pb4md1 and pb4md0)): pb4md1 and pb4md0 select the function of the pb4/tp4/tioca4 pin. bit 9: pb4md1 bit 8: pb4md0 function 0 0 input/output (pb4) (initial value) 1 reserved 1 0 itu input capture/output compare (tioca4) 1 timing pattern output (tp4)
hitachi 412 bits 7 and 6 (pb3 mode (pb3md1 and pb3md0)): pb3md1 and pb3md0 select the function of the pb3/tp3/tiocb3 pin. bit 7: pb3md1 bit 6: pb3md0 function 0 0 input/output (pb3) (initial value) 1 reserved 1 0 itu input capture/output compare (tiocb3) 1 timing pattern output (tp3) bits 5 and 4 (pb2 mode (pb2md1 and pb2md0)): pb2md1 and pb2md0 select the function of the pb2/tp2/tioca3 pin. bit 5: pb2md1 bit 4: pb2md0 function 0 0 input/output (pb2) (initial value) 1 reserved 1 0 itu input capture/output compare (tioca3) 1 timing pattern output (tp2) bits 3 and 2 (pb1 mode (pb1md1 and pb1md0)): pb1md1 and pb1md0 select the function of the pb1/tp1/tiocb2 pin. bit 3: pb1md1 bit 2: pb1md0 function 0 0 input/output (pb1) (initial value) 1 reserved 1 0 itu input capture/output compare (tiocb2) 1 timing pattern output (tp1) bits 1 and 0 (pb0 mode (pb0md1 and pb0md0)): pb0md1 and pb0md0 select the function of the pb0/tp0/tioca2 pin. bit 1: pb0md1 bit 0: pb0md0 function 0 0 input/output (pb0) (initial value) 1 reserved 1 0 itu input capture/output compare (tioca2) 1 timing pattern output (tp0)
hitachi 413 14.3.5 column address strobe pin control register (cascr) cascr is a 16-bit read/write register that allows selection between column address strobe and chip select pin functions. the cascr is initialized to h'5fff by power-on resets but is not initialized for manual resets, standby mode, or sleep mode. bit: 15 14 13 12 11 10 9 8 bit name: cash md1 cash md0 casl md1 casl md0 initial value: 0 1 0 1 1 1 1 1 r/w: r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: initial value: 1 1 1 1 1 1 1 1 r/w: bits 15 and 14 (cash mode (cashmd1 and cashmd0)): cashmd1 and cashmd0 select the function of the cs1 / cash pin. bit 15: cashmd1 bit 14: cashmd0 function 0 0 reserved 1 chip select output ( cs1 ) (initial value) 1 0 column address strobe output ( cash ) 1 reserved bits 13 and 12 (casl mode (caslmd1 and caslmd0)): caslmd1 and caslmd0 select the function of the cs3 / casl pin. bit 13: caslmd1 bit 12: caslmd0 function 0 0 reserved 1 chip select output ( cs3 ) (initial value) 1 0 column address strobe output ( casl ) 1 reserved bits 11? (reserved): this bit always reads as 1. the write value should always be 1.
hitachi 415 section 15 parallel i/o ports 15.1 overview there are two ports, a and b. ports a and b are 16-bit i/o ports. the pins of the ports are all multiplexed for use as general-purpose i/os or for other functions. (use the pin function controller (pfc) to select the function of multiplexed pins.) ports a and b each have one data register for storing pin data. 15.2 port a port a is a 16-pin input/output port, as shown in figure 15.1. the pa3/ cs7 / wait pin of port a has a pull-up mos so that when it is functioning as a wait pin, the wait state control register of the bus state controller can be used to select whether to pull up the wait pin or not. it is not pulled up when the pin is functioning as either pa3 or cs7 . port a pa 15 (input/output)/irq3 (input)/dreq1 (input) pa 14 (input/output)/irq2 (input)/dack1 (output) pa 13 (input/output)/irq1 (input)/dreq0 (input)/tclkb (input) pa 12 (input/output)/irq0 (input)/dack0 (output)/tclka (input) pa 11 (input/output)/dph (input/output)/tiocb1 (input/output) pa 10 (input/output)/dpl (input/output)/tioca1 (input/output) pa 9 (input/output)/ah (output)/irqout (output) pa 8 (input/output)/breq (input) pa 7 (input/output)/back (output) pa 6 (input/output)/rd (output) pa 5 (input/output)/wrh (output) (lbs (output)) pa 4 (input/output)/wrl (output) (wr (output)) pa 3 (input/output)/cs7 (output)/wait (input) pa 2 (input/output)/cs6 (output)/tiocb0 (input/output) pa 1 (input/output)/cs5 (output)/ras (output) pa 0 (input/output)/cs4 (output)/tioca0 (input/output) figure 15.1 port a configuration 15.2.1 register configuration table 15.1 summarizes the port a register.
hitachi 416 table 15.1 port a register name abbreviation r/w initial value address access size port a data register padr r/w h'0000 h'5ffffc0 8, 16, 32 15.2.2 port a data register (padr) padr is a 16-bit read/write register that stores data for port a. the bits pa15dr?a0dr correspond to the pa15/ irq3 / dreq1 ?a0/ cs4 /tioca0 pins. when the pins are used as ordinary outputs, they will output whatever value is written in the padr; when padr is read, the register value will be output regardless of the pin status. when the pins are used as ordinary inputs, the pin status rather than the register value is read directly when padr is read. when a value is written to padr, that value can be written into padr, but it will not affect the pin status. table 15.2 shows the read/write operations of the port a data register. padr is initialized by a power-on reset. however, padr is not initialized for manual reset, standby mode, or sleep mode. bit: 15 14 13 12 11 10 9 8 bit name: pa15dr pa14dr pa13dr pa12dr pa11dr pa10dr pa9dr pa8dr initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pa7dr pa6dr pa5dr pa4dr pa3dr pa2dr pa1dr pa0dr initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w table 15.2 read/write operation of the port a data register (padr) paior pin status read write 0 input pin status can write to padr, but it has no effect on pin status. other function pin status can write to padr, but it has no effect on pin status. 1 output padr value value written is output by pin other function padr value can write to padr, but it has no effect on pin status.
hitachi 417 15.3 port b port b is a 16-bit input/output port as shown in figure 16.2. port b pb 15 (input/output)/tp 15 (output)/irq7 (input) pb 14 (input/output)/tp 14 (output)/irq6 (input) pb 13 (input/output)/tp 13 (output)/irq5 (input)/sck1 (input/output) pb 12 (input/output)/tp 12 (output)/irq4 (input)/sck0 (input/output) pb 11 (input/output)/tp 11 (output)/txd1 (output) pb 10 (input/output)/tp 10 (output)/rxd1 (input) pb 9 (input/output)/tp 9 (output)/txd0 (output) pb 8 (input/output)/tp 8 (output)/rxd0 (input) pb 7 (input/output)/tp 7 (output)/tocxb4 (output)/tclkd (input) pb 6 (input/output)/tp 6 (output)/tocxa4 (output)/tclkc (input) pb 5 (input/output)/tp 5 (output)/tiocb4 (output) pb 4 (input/output)/tp 4 (output)/tioca4 (output) pb 3 (input/output)/tp 3 (output)/tiocb3 (input/output) pb 2 (input/output)/tp 2 (output)/tioca3 (input/output) pb 1 (input/output)/tp 1 (output)/tiocb2 (input/output) pb 0 (input/output)/tp 0 (output)/tioca2 (input/output) figure 15.2 port b configuration 15.3.1 register configuration table 15.3 summarizes the port b register. table 15.3 port b register name abbreviation r/w initial value address access size port b data register pbdr r/w h'0000 h'5ffffc2 8, 16, 32
hitachi 418 15.3.2 port b data register (pbdr) pbdr is a 16-bit read/write register that stores data for port b. the bits pb15dr?b0dr correspond to the pb15/tp15/ irq7 ?b0/tp0/tioca2 pins. when the pins are used as ordinary outputs, they will output whatever value is written in the pbdr; when pbdr is read, the register value will be output regardless of the pin status. when the pins are used as ordinary inputs, the pin status rather than the register value is read directly when pbdr is read. when a value is written to pbdr, that value can be written into pbdr, but it will not affect the pin status. when the pin function is set to timing pattern output and the tpc output is enabled by the tpc next data enable register (nder), no value can be written to pbdr. table 15.4 shows the read/write operations of the port b data register. pbdr is initialized by a power-on reset. however, pbdr is not initialized for a manual reset, standby mode, or sleep mode. bit: 15 14 13 12 11 10 9 8 bit name: pb15dr pb14dr pb13dr pb12dr pb11dr pb10dr pb9dr pb8dr initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w bit: 7 6 5 4 3 2 1 0 bit name: pb7dr pb6dr pb5dr pb4dr pb3dr pb2dr pb1dr pb0dr initial value: 0 0 0 0 0 0 0 0 r/w: r/w r/w r/w r/w r/w r/w r/w r/w table 15.4 read/write operation of the port b data register (pbdr) pbior pin status read write 0 input pin status can write to pbdr, but it has no effect on pin status tpn pin status disabled other function pin status can write to pbdr, but it has no effect on pin status 1 output pbdr value value written is output by pin tpn pbdr value disabled other function pbdr value can write to pbdr, but it has no effect on pin status tpn: timing pattern output
hitachi 419 section 16 rom 16.1 overview the sh7020 microcomputer has 16 kbytes of on-chip rom (mask rom). the sh7021 microcomputer has 32 kbytes of on-chip rom (mask rom or prom). the on-chip rom is connected to the cpu and the direct memory access controller (dmac) through a 32-bit data bus (figure 16.1). the cpu can access the on-chip rom in 8-, 16- and 32-bit widths and the dmac can access the rom in 8- and 16-bit widths. data in the on-chip rom can always be accessed in one cycle.
420 hitachi h'0000000 h'0000004 h'0000001 h'0000005 h'0000002 h'0000006 h'0000003 h'0000007 h'0003ffc note: h'0003ffd h'0003ffe h'0003fff on-chip rom internal data bus (32 bits) h'0000000 h'0000004 h'0000001 h'0000005 h'0000002 h'0000006 h'0000003 h'0000007 h'0007ffc h'0007ffd h'0007ffe h'0007fff on-chip rom internal data bus (32 bits) the addresses shown in the figure are the first shadow addresses in the on-chip rom space. sh7020 sh7021 figure 16.1 block diagram of rom the operating mode determines whether the on-chip rom is valid or not. the operating mode is selected using mode-setting pins md0-md2 as shown in table17.1. if you are using the on-chip rom, select mode 2; if you are not, select mode 0 or 1. the on-chip rom is allocated to address h'0000000?'0003fff (sh7020), h'0000000?'0007fff (sh7021) of memory area 0. memory area 0 (h'0000000-h'0ffffff and h'8000000?'8ffffff) is divided into 16-kbyte (sh7020) or 32-kbyte (sh7021) shadows. no matter which shadow is accessed, the on-chip rom is accessed. see section 8, bus state controller, for more information on shadows.
hitachi 421 table 16.1 operating modes and rom mode setting pin operating mode md2 md1 md0 area 0 mode 0 (mcu mode 0) 0 0 0 on-chip rom invalid, external 8-bit space mode 1 (mcu mode 1) 0 0 1 on-chip rom invalid, external 16-bit space mode 2 (mcu mode 2) 0 1 0 on-chip rom valid mode 7 (prom mode) 111 0: low 1: high when the sh7021 is set to prom mode, the prom version can write programs exactly like ordinary eprom using a general purpose eprom writer. 16.2 prom mode 16.2.1 setting the prom mode to program the on-chip prom, set the pins as shown in figure 16.2 and use the chip in prom mode. 16.2.2 socket adapter pin correspondence and memory map mount the socket adapter to the sh7021 as shown in figure 16.2. this allows the on-chip prom to be programmed in exactly the same way as ordinary 32-pin eproms (hn27c101). figure 16.2 shows the correspondence of sh7021 pins and hn27c101 pins. figure 16.3 shows the memory map of the on-chip rom. the address range of the hn27c101 (128 kbytes) is h'00000?'1ffff. the on-chip prom (34 kbytes) is not found in h'08000?'1ffff. when programming with a prom writer, the program address range must be set to h'00000 h'07fff. the data for the h'08000?'1ffff address area should all be h'ff. set byte mode, not page mode.
422 hitachi pin number 76 74 1 2 3 5 6 7 8 9 20 21 22 23 25 26 27 28 29 30 31 33 34 35 36 37 39 53 54 40 42 13, 38, 63, 73, 80, 88 77 78 79 4, 15, 24, 32, 41, 50, 59, 70, 81, 82,92 pin other than the above pin name res nmi ad0 ad1 ad2 ad3 ad4 ad5 ad6 ad7 a0/hbs a1 a2 a3 a4 a5 a6 a7 a8 a9 a10 a11 a12 a13 a14 a15 a16 pa2/cs6/tiocb0 pa3/cs7/wait a17 a18 v cc md0 md1 md2 v ss nc (release) pin number 1 26 13 14 15 17 18 19 20 21 12 11 10 9 8 7 6 5 27 24 23 25 4 28 29 3 2 32 16 pin name v pp a9 i/o0 i/o1 i/o2 i/o3 i/o4 i/o5 i/o6 i/o7 a0 a1 a2 a3 a4 a5 a6 a7 a8 oe a10 a11 a12 a13 a14 a15 a16 pgm ce v cc v ss 31 22 sh7021 hn27c101 eprom socket adapter v pp : prom program power adapter a16ea0: address input i/o7ei/o0: data input/ output oe: output enable pgm: program enable ce: chip enable figure 16.2 correspondence between sh7021 pins and hn27c101 pins
hitachi 423 on-chip rom space (area 0) h'0000 h'7fff h'0000000 h'0007fff addresses in mcu modes 0, 1, and 2* addresses in prom mode note: addresses in the figure are the uppermost shadow addresses of the on-chip rom space. figure 16.3 memory map of on-chip rom 16.3 prom programming the write/verify specifications in prom mode are the same as for the standard eprom hn27c101. the page program system is not supported, so do not set the prom writer to the page programming mode . naturally, prom writers that only support the page programming mode cannot be used. when selecting a prom writer, check that the high-speed, high-reliability programming system for each byte is supported. 16.3.1 selecting the programming mode there are two on-chip prom programming modes: write and verify (which reads and confirms the data written). use the pins to select the modes (table 16.2).
424 hitachi table 16.2 select prom programming mode pin mode ce oe pgm v pp v cc i/o7?/o0 a16?0 write 0 1 0 v pp v cc data input address input verify 0 0 1 data output program inhibit 0 0 0 high impedance 01 1 10 0 11 1 symbols: 0: low 1: high v pp : v pp level v cc : v cc level 16.3.2 write/verify and electrical characteristics write/verify: write/verify can be accomplished by an efficient high-speed high-reliability programming system. this system can write data quickly and accurately without placing voltage stress on the device. the basic flowchart for this high-speed, high-reliability programming system is shown in figure 16.4.
hitachi 425 start set eprom writer to write/verify mode (v cc = 6.0 v 0.25 v, v pp = 12.5 v 0.3 v) address = 0 n = 0 n + 1 n data write (t pw = 0.2 ms 5%) data write (t opw = (0.2 n) ms) verify result ok? no yes final address? no yes set eprom writer to read mode (v cc = 5.0 v 0.25 v, v pp = v cc ) results of reading all address ok? no yes end no good no v cc : power supply v pp : prom program power supply t pw : initial programming pulse width t opw : over programming pulse width n = 25? yes address + 1 address figure 16.4 basic flowchart of high-speed high-reliability programming
426 hitachi electrical characteristics: tables 16.3 and 16.4 show the electrical characteristics of programming. figure 16.5 shows the timing. table 16.3 dc characteristics (v cc = 6.0 v ?0.25 v, v pp = 12.5 ?0.3 v, v ss = 0 v, ta = 25 ?5?c) item pins symbol min typ max unit measurement conditions input high voltage i/o7?/o0, a16?0, oe , ce , pgm v ih 2.4 v cc + 0.3 v input low voltage i/o7?/o0, a16?0, oe , ce , pgm v il ?.3 0.8 v output high voltage i/o7?/o0 v oh 2.4 v i oh = -200 m a output low voltage i/o7?/o0 v ol 0.45 v i ol = 1.6 ma input leak current i/o7?/o0, a16?0, oe , ce , pgm |i li |2 m av in = 5.25 v/0.5 v v cc current i cc 40 ma v pp current i pp 40 ma
hitachi 427 table 16.4 ac characteristics (v cc = 6.0 v ?0.25 v, v pp = 12.5 ?0.3 v, v ss = 0 v, ta = 25 ?5?c) item symbol min typ max unit measurement conditions address setup time t as 2 m s figure 16.5* 1 oe setup time t oes 2 m s data setup time t ds 2 m s address hold time t ah 0 m s data hold time t dh 2 m s data output disable time t df * 2 130 ns v pp setup time t vps 2 m s pgm pulse width in initial programming t pw 0.19 0.20 0.21 ms pgm pulse width in over programming t opw * 3 0.19 5.25 ms v cc setup time t vcs 2 m s ce setup time t ces 2 m s data output delay time t oe 0 150 ns notes: 1. input pulse level: 0.45?.4 v input rise, fall time 20 ns input timing reference levels: 0.8 v, 2.0 v output timing reference levels: 0.8 v, 2.0 v 2. t df is defined as when output reaches the release state and the output level could not be referenced. 3. t opw is defined as the value given in the flowchart.
428 hitachi address data v pp v cc ce pgm oe write verify t ah read data t df t dh t ds t as t vps write data t vcs t ces t pw (t opw ) t oes t oe v pp v cc v cc + 1 v cc note: t opw is defined as the value given in the flowchart. figure 16.5 write/verify timing 16.3.3 points to note about writing 1. always write using the prescribed voltage and timing. the write voltage (programming voltage) v pp is 12.5 v (when the eprom writer is set to the hitachi specifications for hn27c101, v pp becomes 12.5 v.) applying a voltage in excess of the rated voltage may damage the device. pay particular attention to overshooting in the eprom writer. 2. before programming, always check that the indexes of the eprom writer socket, socket adapter, and devices are consistent with each other. if they are not mounted in the proper location, an overcurrent may be generated, damaging the device. 3. do not touch the socket adapter or device during writing. contact can cause malfunctions that prevent data from being written accurately.
hitachi 429 4. you cannot write in the page programming mode. always set the equipment to the byte programming mode. 5. the capacity of the on-chip rom is 32 kbytes, so the data of prom writer addresses h'08000?'1ffff should be h'ff. always set the range for prom addresses to h'0000 h'7fff. 6. when write errors occur on consecutive addresses, stop writing. check to see if there are any abnormalities in the eprom writer and socket adapter. 16.3.4 reliability after writing after programming, we recommend letting the device stand at high temperature (125?50?) for 24?8 hours to increase the reliability of data retention. letting it stand at high temperature is a type of screening method that can get rid of initial data retention defects of the on-chip prom's memory cell within a short period of time. figure 16.6 shows the flow from programming of the on-chip prom, including screening, to mounting on the device board. writing and verification of program mount on board flow chart from figure 16.4 let stand in nonconductive, high temperature environment (125?50 c, 24?8 hours) data read and verification (v cc = 5.0 v) figure 16.6 screening flow if abnormalities are found when the program is written and verified or the program is read and checked after the writing/verification or letting the chip stand at high temperature, contact hitachi's engineering departments.
hitachi 431 section 17 ram 17.1 overview the sh7020 and sh7021 has 1-kbytes of on-chip ram. the on-chip ram is linked to the cpu and direct memory access controller (dmac) with a 32-bit data bus (figure 17.1). the cpu can access data in the on-chip ram in byte, word, or long word units. the dmac can access byte or word data. on-chip ram data can always be accessed in one state, making the ram ideal for use as a program area, stack area, or data area, which require high-speed access. the contents of the on-chip ram are held in both the sleep and standby modes. memory area 7 addresses h'ffffc00 to h'fffffff are allocated to the on-chip ram. h'ffffc00 h'ffffc04 h'ffffc01 h'ffffc05 h'ffffc02 h'ffffc06 h'ffffc03 h'ffffc07 h'ffffffc h'ffffffd h'ffffffe h'ffffff on-chip ram internal data bus (32 bits) figure 17.1 block diagram of ram 17.2 operation accesses to addresses h'ffffc00?'fffffff are directed to the on-chip ram. memory area 7 (h'f000000?'fffffff) is divided into shadows in 1 kbyte units. all shadow accesses are on- chip ram accesses. for more information on shadows, see section 8, bus state controller.
hitachi 433 section 18 power-down states 18.1 overview in the power-down mode, all cpu functions are halted. this lowers power consumption dramatically. 18.1.1 power-down modes the sh microprocessor has two power-down modes. 1. sleep mode 2. standby mode the sleep mode and standby mode are entered from the program execution state according to the transition conditions given in table 18.1. table 18.1 also describes procedures for canceling each mode and the states of the cpu and peripheral functions. table 18.1 power-down states state mode entering procedure clock cpu peripheral functions cpu registers ram i/o ports canceling procedure sleep mode execute sleep instruction with sby bit set to 0 in sbycr run halt run held held held interrupt dma address error power-on reset manual reset standb y mode execute sleep instruction with sby bit set to 1 in sbycr halt halt halt* 1 held held held or high-z* 2 nmi power-on reset manual reset sbycr: standby control register sby: standby bit notes: 1. some of the registers of the on-chip peripheral modules are not initialized in the standby mode. for details, see table 18.3, status of registers in the standby mode in section 18.4.1, transition to the standby mode, or the descriptions of registers given where the on-chip peripheral modules are covered. 2. the status of i/o ports in the standby mode are set by the port high-impedance bit (hiz) of the sbycr. see section 18.2, standby control register (sbycr) for details. the status of pins other than the i/o ports are described in appendix b, pin states.
hitachi 434 18.1.2 register table 18.2 summarizes the register related to the power-down state. table 18.2 standby control register (sbycr) name abbreviation r/w initial value address access size standby control register sbycr r/w h'1f h'5ffffbc 8, 16, 32 18.2 standby control register (sbycr) the standby control register (sbycr) is an 8-bit register that can be read or written to. it is set in order to enter the standby mode and also sets the port states in standby mode. the sbycr is initialized to h'1f when reset. bit: 7 6 5 4 3 2 1 0 bit name: sby hiz initial value: 0 0 0 1 1 1 1 1 r/w: r/w r/w bit 7 (standby (sby)): sby enables transition to the standby mode. the sby bit cannot be set to 1 while the timer enable bit (bit tme) in timer control/status register tcsr of watchdog timer wdt is set to 1. to enter the standby mode, clear the tme bit to 0 to halt the wdt and set the sby bit. sby description 0 executing sleep instruction puts the lsi into sleep mode (initial value) 1 executing sleep instruction puts the lsi into standby mode bit 6 (port high-impedance (hiz)): hiz selects whether i/o ports remain in their previous states during standby, or are placed in the high-impedance state when the standby mode is entered. the hiz bit cannot be set to 1 while the tme bit is set to 1. to place the pins of the i/o ports in high impedance, clear the tme bit to 0 before setting the hiz bit. hiz description 0 port states are maintained during standby (initial value) 1 ports are placed in the high-impedance state in standby
hitachi 435 bits 5? (reserved): bit 5 is a read-only bit that always reads as 0. only write 0 to bit 5. writing to bits 4? is disabled. these bits always read 1. 18.3 sleep mode 18.3.1 transition to the sleep mode execution of the sleep instruction when the standby bit (sby) in the standby control register (sbycr) is cleared to 0 causes a transition from the program execution state to the sleep mode. although the cpu halts immediately after executing the sleep instruction, the contents of its internal registers remain unchanged. the on-chip peripheral modules do not halt in the sleep mode. 18.3.2 canceling the sleep mode the sleep mode is canceled by an interrupt, dma address error, power-on reset, or manual reset. cancellation by an interrupt: when an interrupt occurs, the sleep mode is canceled and interrupt exception processing is executed. the sleep mode is not canceled if the interrupt cannot be accepted because its priority level is equal to or less than the mask level set in the cpu? status register (sr). likewise, the sleep mode is not canceled if the interrupt is disabled by the on-chip peripheral module. cancellation by a dma address error: if the dmac operates during the sleep mode and a dma address error occurs, the sleep mode is canceled and dma address error exception- processing is executed. cancellation by a power-on reset: if the res signal goes low while the nmi signal is high, the sleep mode is canceled and the power-on reset state is entered. if the nmi signal is brought from low to high in order to set the lsi for power-on resets, an nmi interrupt will occur whenever the rising edge of the nmi is selected as the valid edge (in nmi edge select bit nmie of the interrupt control register icr of the interrupt controller). when this occurs, the nmi interrupt cancels the sleep mode. cancellation by a manual reset: if the res signal goes low while the nmi signal is low, the sleep mode is canceled and the manual reset state is entered. if the nmi signal is brought from high to low in order to set the lsi for manual resets, the sleep mode will be canceled by an nmi interrupt whenever the falling edge of the nmi is selected as the valid edge (in the nmie bit).
hitachi 436 18.4 standby mode 18.4.1 transition to the standby mode to enter the standby mode, set the standby bit (sby) to 1 in the standby control register (sbycr), then execute the sleep instruction. the lsi moves from the program execution state to the standby mode. the standby mode greatly reduces power consumption by halting not only the cpu, but the clock and on-chip peripheral modules as well. some registers of the on-chip peripheral modules are initialized, others are not (see table 18.3). as long as the specified voltage is supplied, however, cpu register contents and on-chip ram data are held. the i/o port state (hold or high impedance) depends on the port high-impedance bit (hiz) in the sbycr. for details on the states of these pins, see appendix b. pin states.
hitachi 437 table 18.3 register states in the standby mode module register initialized registers that hold data interrupt controller (intc) all registers user break controller (ubc) all registers bus state controller (bsc) all registers pin function controller (pfc) all registers i/o ports all registers direct memory access controller (dmac) all registers watchdog timer (wdt) bits 7? (ovf, wt/ it , tme) of the timer control status register (tcsr) reset control/status register (rstcsr) bits 2? (cks2?ks0) of the timer control status register (tcsr) timer counter (tcnt) 16-bit integrated timer pulse unit (itu) all registers programmable timing pattern controller (tpc) all registers serial communications interface (sci) receive data register (rdr) transmit data register (tdr) serial mode register (smr) serial control register (scr) serial status register (ssr) bit rate register (bbr) power-down state register standby control register (sbycr)
hitachi 438 18.4.2 canceling the standby mode the standby mode is canceled by an nmi interrupt, a power-on reset, or a manual reset. cancellation by an nmi: when a rising edge or falling edge (as selected by the nmie bit in interrupt control register icr of interrupt controller intc) is detected at the nmi pin, the clock oscillator begins operating. at first, clock pulses are supplied only to the watchdog timer. after the time that was selected before entering the standby mode using clock select bits 2? (cks2?ks0) in the timer control/status register tcsr of the watchdog timer wdt, the watchdog timer overflows. after the overflow, the clock is considered stable and supplied to the entire chip. the standby mode is canceled and the nmi exception-processing sequence begins. when the standby mode is cleared by an nmi interrupt, bits cks2?ks0 must be set so that the wdt overflow interval is equal to or greater than the clock settling time. when the standby mode is cleared when the fall edge has been selected in the nmi bit, be sure that the nmi pin is high when standby is entered (when the clock is halted) and low when the chip returns from standby (clock starts up after oscillator is stabilized). likewise, when the standby mode is cleared when the rise edge has been selected in the nmi bit, be sure that the nmi pin is low when standby is entered (clock halted) and high when the chip returns from standby (clock starts up after oscillator is stabilized). cancellation by a power-on reset: if the res signal goes low while the nmi signal is high, the standby mode is canceled and the power-on reset state is entered. if the nmi signal is brought from low to high in order to set the lsi for power-on resets, the standby mode will not be canceled by an nmi interrupt, because the nmi signal is initialized for the falling edge in the standby mode (by the nmie bit). cancellation by a manual reset: if the res signal goes low while the nmi signal is low, the standby mode is canceled and the manual reset state is entered. if the nmi signal is brought from high to low in order to set the lsi for manual resets, the standby mode will first be canceled by an nmi interrupt, because the nmi signal is initialized for the falling edge in the standby mode (by the nmie bit).
hitachi 439 18.4.3 standby mode application in this example, the standby mode is entered on the falling edge of the nmi signal and canceled on the rising edge of the nmi signal. figure 18.1 shows the timing. after an nmi interrupt is accepted (high goes to low) while the nmi edge select bit nmie in the interrupt control register icr is cleared to 0 to select detection of the falling edge, the nmi exception service routine sets the nmie to 1 (selecting detection of the rising edge) and sets the sby bit to 1. finally, it executes a sleep instruction to enter the standby mode. the standby mode is canceled on the rising edge of the nmi signal. oscillator ck nmi nmie ssby clock setting time nmi exception processing exception service routine sby = 1 sleep instruction standby mode oscillation start time time set in wdt nmi exception processing figure 18.1 nmi timing for the standby mode (example)
hitachi 441 section 19 electrical characteristics 19.1 absolute maximum ratings table 19.1 absolute maximum ratings item symbol rating unit power supply voltage v cc ?.3 to +7.0 v program voltage v pp ?.3 to +13.5 v input voltage vin ?.3 to v cc + 0.3 v operating temperature topr ?0 to +75* ?c storage temperature tstg ?5 to +125 ?c caution: operating the lsi in excess of the absolute maximum rating may result in permanent damage. note: normal products: topr = ?0 to +85 c for wide-temperature range products
hitachi 442 19.2 dc characteristics table 19.2 lists dc characteristics. table 19.3 lists the permissible output current values. usage conditions: the current consumption value is measured under conditions of v ih min = v cc ?0.5 v and v il max = 0.5 v with no load on any output pin and the on-chip pull-up mos off. table 19.2 dc characteristics (1) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min typ max unit measurement conditions input high- res , nmi, md2?d0 v ih v cc ?0.7 v cc + 0.3 v level extal v cc 0.7 v cc + 0.3 v voltage other input pins 2.2 v cc + 0.3 v input low- res , nmi, md2?d0 v il ?.3 0.5 v level voltage other input pins ?.3 0.8 v schmidt trigger pa13?a10, pa2, pa0, pb7 v t + 4.0 v input pb0 v t 1.0 v voltage v t + ? t 0.4 v input leak res |iin| 1.0 m a vin = 0.5 to v cc ?0.5 v current nmi, md2?d0 1.0 m a vin = 0.5 to v cc ?0.5 v 3-state leak current (while off) ports a and b, cs3 cs0 , a21 a0, ad15?d0 |i tsi | 1.0 m a vin = 0.5 to v cc ?0.5 v input pull- up mos current pa3 ?p 20 300 m a vin = 0v output all output pins v oh v cc ?0.5 v i oh = ?00 m a high-level voltage 3.5 v i oh = ? ma
hitachi 443 table 19.2 dc characteristics (1) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products . item symbol min typ max unit measurement conditions output low level all output pins v ol 0.4 v i ol = 1.6 ma voltage 1.2 v i ol = 8 ma input capacitance res cin 30 pf nmi 30 pf all other input pins 20 pf current consumption ordinary i cc 65 80 ma f = 12.5 mhz operation 75 90 ma f = 16.6 mhz 90 100 ma f = 20 mhz sleep 30 50 ma f = 12.5 mhz 35 55 ma f = 16.6 mhz 40 60 ma f = 20 mhz standby 0.01 5 m a ta 50 c 20.0 m a50 c < ta ram stand-by voltage v ram 2.0 v usage notes: 1. current dissipation values are for v ih min = v cc - 0.5 v and v il max = 0.5 v with all output pins unloaded and the on-chip pull-up transistors in the off state. 5. the ztat and mask versions have the same functions, and the electrical characteristics of both are within specification, but characteristic-related performance values, operating margins, noise margins, noise emission, etc., are different. caution is therefore required in carrying out system design, and when switching between ztat and mask versions. vin = 0 v input signal f = 1 mhz ta = 25 c
hitachi 444 table 19.2 dc characteristics (2) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min typ max unit measurement conditions input high- res , nmi, md2?d0 v ih v cc ?0.7 v cc + 0.3 v level voltage extal v cc 0.7 v cc + 0.3 v other input pins 2.2 v cc + 0.3 v input low- level voltage res , nmi, md2?d0 v il ?.3 0.5 v other input pins ?.3 0.8 v schmidt pa13?0, pa2, v t + 4.0 v trigger input pa0, pb7?b0 v t 1 v voltage v t + ? t 0.4 v input leak current res |iin| 1.0 m a vin = 0.5 to v cc ?0.5 v nmi, md2?d0 1.0 m a vin = 0.5 to v cc ?0.5 v 3-state leak current (while off) ports a and b, cs3 cs0 , a21 a0, ad15?d0 |i tsi | 1.0 m a vin = 0.5 to v cc ?0.5 v input pull-up mos current pa3 ?p 20 300 m a vin = 0 v output high- all output pins v oh v cc ?0.5 v i oh = ?00 m a level voltage 3.5 v i oh = ? ma output low all output pins v ol 0.4 v i ol = 1.6 ma level voltage 1.2 v i ol = 8 ma
hitachi 445 table 19.2 dc characteristics (2) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products . item symbol min typ max unit measurement conditions input res cin 30 pf capacitance nmi 30 pf all other input pins 20 pf current consumption ordinary operation i cc 65 80 ma f = 12.5 mhz 75 90 ma f = 16.6 mhz sleep 30 50 ma f = 12.5 mhz 35 55 ma f = 16.6 mhz standby 0.01 5 m a ta 50 c 20.0 m a50 c < ta ram stand-by voltage v ram 2.0 v vin = 0 v input signal f = 1 mhz ta = 25 c
hitachi 446 table 19.2 dc characteristics (3) conditions: v cc = 3.0 v to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min typ max unit measurement conditions input high- level voltage res , nmi, md2?d0 v ih v cc 0.9 v cc + 0.3 v extal v cc 0.7 v cc + 0.3 v other input pins v cc 0.7 v cc + 0.3 v input low- level voltage res , nmi, md2?d0 v il ?.3 v cc 0.1 v other input pins ?.3 v cc 0.2 v schmidt trigger input pa13?0, pa2, pa0, pb7?b0 v t + v cc 0.9 v voltage v t v cc 0.2 v v t + ? t v cc 0.07 v input leak current res |iin| 1.0 m a vin = 0.5 to v cc ?0.5 v nmi, md2?d0 1.0 m a vin = 0.5 to v cc ?0.5 v 3-state leak current (while off) ports a and b, cs3 cs0 , a21 a0, ad15?d0 |i tsi | 1.0 m a vin = 0.5 to v cc ?0.5 v input pull-up mos current pa3 ?p 20 300 m a vin = 0v output high- all output pins v oh v cc ?0.5 v i oh = ?00 m a level voltage v cc ?1.0 v i oh = ? ma output low level voltage all output pins v ol 0.4 v i ol = 1.6 ma 1.2 v i ol = 8 ma
hitachi 447 table 19.2 dc characteristics (3) (cont) conditions: v cc = 3.0 v to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products . item symbol min typ max unit measurement conditions input res cin 30 pf capacitance nmi 30 pf all other input pins 20 pf current consumption ordinary operation i cc 65 80 ma f = 12.5 mhz sleep 30 50 ma f = 12.5 mhz standby 0.01 5.0 m a ta 50 c 20 m a50 c < ta ram stand-by voltage v ram 2.0 v vin = 0 v input signal f = 1 mhz ta = 25 c
hitachi 448 table 19.3 permitted output current values case a: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* case c: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. 12.5 mhz item symbol min typ max unit output low-level permissible current (per pin) i ol 10 ma output low-level permissible current (total) ? i ol 80 ma output high-level permissible current (per pin) ? oh 2.0 ma output high-level permissible current (total) ? i oh 25 ma caution: to ensure lsi reliability, do not exceed the value for output current given in table 19.3.
hitachi 449 19.3 ac characteristics the following ac timing chart represents the ac characteristics, not signal functions. for signal functions, see the explanation in the text. 19.3.1 clock timing table 19.4 clock timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. case a case b sym- 12.5 mhz 16.6 mhz 20 mhz item bol min max min max min max unit figures extal input high level pulse width t exh 20 10 10 ns 19.1 extal input low level pulse width t exl 20 10 10 ns extal input rise time t exr 1055ns extal input fall time t exf 1055ns clock cycle time t cyc 80 60 500 50 500 ns 19.1, 19.2 clock high pulse width t ch 30 20 20 ns 19.2 clock low pulse width t cl 30 20 20 ns clock rise time t cr 1055ns clock fall time t cf 1055ns reset oscillation settling time t osc1 10 10 10 ms 19.3 software standby oscillation settling time t osc2 10 10 10 ms
hitachi 450 t cyc t exh extal t exl t exf v ih v il t exr 1/2 v cc figure 19.1 extal input timing t cyc t ch t cr ck t cl t cf figure 19.2 system clock timing t osc2 t osc1 ck v cc res figure 19.3 oscillation settling time
hitachi 451 19.3.2 control signal timing table 19.5 control signal timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. case a case b 12.5 mhz 16.6 mhz 20 mhz item symbol min max min max min max unit figure res setup time t ress 320 240 200 ns 19.4 res pulse width t resw 20 20 20 t cyc nmi reset setup time t nmirs 320 240 200 ns nmi reset hold time t nmirh 320 240 200 ns nmi setup time t nmis 160 120 100 ns 19.5 nmi hold time t nmih 80 60 50 ns irq0 irq7 setup time (edge detection time) t irqes 160 120 100 ns irq0 irq7 setup time (level detection time) t irqls 160 120 100 ns irq0 irq7 hold time t irqeh 80 60 50 ns irqout output delay time) t irqod 80 60 50 ns 19.6 bus request setup time t brqs 80 60 50 ns 19.7 bus acknowledge delay time 1 t bacd1 80 60 50ns bus acknowledge delay time 2 t bacd2 80 60 50ns bus 3-state delay time t bzd 80 60 50ns
hitachi 452 ck res nmi t ress t ress t nmirs t resw t nmirh figure 19.4 reset input timing irq edge nmi t nmis ck t nmih t irqes t irqeh irq level t irqls figure 19.5 interrupt signal input timing
hitachi 453 irqout ck t irqod t irqod figure 19.6 interrupt signal output timing t brqs t brqs t bacd1 t bzd t bzd t bacd2 ck breq (input) back (output) a21?0 rd , wr , ras , cas , csn figure 19.7 bus release timing
hitachi 454 19.3.3 bus timing table 19.6 bus timing (1) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products.
hitachi 455 item symbol min max unit figures address delay time t ad ?0 *1 ns 19.8, 19.9, 19.11?9.14, 19.19, 19.20 cs delay time 1 t csd1 25 ns 19.8, 19.9, 19.20 cs delay time 2 t csd2 ?5ns cs delay time 3 t csd3 20 ns 19.19 cs delay time 4 t csd4 ?0ns access time 1 *6 from read strobe 35% duty *2 t rdac1 t cyc 0.65 20 ns 19.8 50% duty t cyc 0.5 ?20 ns access time 2 *6 from read strobe 35% duty *2 t rdac2 t cyc (n+1.65) ?20 *3 ns 19.9, 19.10 50% duty t cyc (n+1.5) ?20 *3 ?s access time 3 *6 from read strobe 35% duty *2 t rdac3 t cyc (n+0.65) ?20 *3 ns 19.19 50% duty t cyc (n+0.5) ?20 *3 ?s read strobe delay time t rsd 20 ns 19.8, 19.9, 19.11?9.15, 19.19, 19.24?9.28 read data setup time t rds 15 ns 19.8, 19.9, 19.11?9.14, read data hold time t rdh 0ns 19.19 write strobe delay time 1 t wsd1 20 ns 19.9, 19.13, 19.14, 19.19, 19.20 write strobe delay time 2 t wsd2 20 ns 19.9, 19.13, 19.14, 19.19 write strobe delay time 3 t wsd3 20 ns 19.11, 19.12 write strobe delay time 4 t wsd4 20 ns 19.11, 19.12, 19.20 write data delay time 1 t wdd1 35 ns 19.9, 19.13, 19.14, 19 write data delay time 2 t wdd2 20 ns 19.11, 19.12 write data hold time t wdh 0 ns 19.9, 19.11?9.14
hitachi 456 table 19.6 bus timing (1) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures parity output delay time 1 t wpdd1 40 ns 19.9, 19.13, 19.14 parity output delay time 2 t wpdd2 20 ns 19.11, 19.12 parity output hold time t wpdh 0 ns 19.9, 19.11?9.14 wait setup time t wts 14 ns 19.10, 19.15, 19.19 wait hold time t wth 10 ns read data access time 1 *6 t acc1 t cyc ?30* 4 ns 19.8, 19.11, 19.12 read data access time 2 *6 t acc2 t cyc (n+2) 30 *3 ns 19.9, 19.10, 19.13, 19.14 ras delay time 1 t rasd1 20 ns 19.11?9.14, ras delay time 2 t rasd2 ?0ns 19.16?9.18 cas delay time 1 t casd1 20 ns 19.11 cas delay time 2 t casd2 20 ns 19.13, 19.14, cas delay time 3 t casd3 ?0ns 19.16?9.18 column address setup time t asc 0 ns 19.11, 19.12 read data access time 35% duty *2 t cac1 t cyc 0.65 19 ?s from cas 1 *6 50% duty t cyc 0.5 ?19 ns read data access time from cas 2 *6 t cac2 t cyc (n+1) 25 *3 ns 19.13, 19.14, 19.15 read data access time from ras 1 *6 t rac1 t cyc 1.5 ?20 ns 19.11, 19.12 read data access time from ras 2 *6 t rac2 t cyc (n+2.5) 20 *3 ns 19.13, 19.14, 19.15 high-speed page mode cas precharge time t cp t cyc 0.25 ns 19.12
hitachi 457 table 19.6 bus timing (1) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures ah delay time 1 t ahd1 20 ns 19.19 ah delay time 2 t ahd2 ?0 ns multiplexed address delay time t mad ?0 ns multiplexed address hold time t mah 0 ns dack0, dack1 delay time 1 t dacd1 23 ns 19.8, 19.9, 19.11 19.14, 19.19, 19.20 dack0, dack1 delay time 2 t dacd2 ?3 ns dack0, dack1 delay time 3 t dacd3 20 ns 19.9, 19.13, 19.14, 19.19 dack0, dack1 delay time 4 t dacd4 20 ns 19.11, 19.12 dack0, dack1 delay time 5 t dacd5 ?0 ns read delay time 35% duty *2 t rdd ? cyc 0.35 + 12 ns 19.8, 19.9, 19.11- 50% duty t cyc 0.5 + 15 ns 19.15, 19.19, 19.24- 19.28 data setup time for cas t ds 0 *5 ns 19.11, 19.13 cas setup time for ras t csr 10 ns 19.16, 19.17, 19.18 row address hold time t rah 10 ns 19.11, 19.13 write command hold time t wch 15 ns write command 35% duty *2 t wcs 0 ns 19.11 setup time 50% duty 0 ns access time from cas precharge *6 t acp t cyc - 20 ns 19.12 notes: 1. hbs and lbs signals are 25 ns. 2. when frequency is 10 mhz or more. 3. n is the number of wait cycles. 4. access time from addresses a0 to a21 is tcyc-25. 5. ? ns for parity output of dram long-pitch access. 6. it is not necessary to meet the t rds specification as long as the access time specification is met.
hitachi 458 table 19.7 bus timing (2) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures address delay time t ad ?5 *1 ns 19.8, 19.9, 19.11?9.14, 19.19, 19.20 cs delay time 1 t csd1 30 ns 19.8, 19.9, 19.20 cs delay time 2 t csd2 ?5ns cs delay time 3 t csd3 25 ns 19.19 cs delay time 4 t csd4 ?5ns access time 1 *6 from read strobe 35% duty *2 t rdac1 t cyc 0.65 20 ns 19.8 50% duty t cyc 0.5 20 ?s access time 2 *6 from read strobe 35% duty *2 t rdac2 t cyc (n + 1.65) ?20 *3 ns 19.9, 19.10 50% duty t cyc (n + 1.5) ?20 *3 ?s access time 3 *6 from read strobe 35% duty *1 t rdac3 t cyc (n + 0.65) ?20 *3 ns 19.19 50% duty t cyc (n + 0.5) ?20 *3 ?s read strobe delay time t rsd 25 ns 19.8, 19.9, 19.19 read data setup time t rds 15 ns 19.8, 19.9, 19.11?9.14, read data hold time t rdh 0 ns 19.19 write strobe delay time 1 t wsd1 25 ns 19.9, 19.13, 19.14, 19.19, 19.20 write strobe delay time 2 t wsd2 25 ns 19.9, 19.13, 19.14, 19.19 write strobe delay time 3 t wsd3 25 ns 19.11, 19.12 write strobe delay time 4 t wsd4 25 ns 19.11, 19.12, 19.20 write data delay time 1 t wdd1 45 ns 19.9, 19.13, 19.14, 19.19 write data delay time 2 t wdd2 25 ns 19.11, 19.12 write data hold time t wdh 0 ns 19.9, 19.11?9.14 parity output delay time 1 t wpdd1 45 ns 19.9, 19.13, 19.14 parity output delay time 2 t wpdd2 25 ns 19.11, 19.12 parity output hold time t wpdh 0 ns 19.9, 19.11?9.14
hitachi 459 table 19.7 bus timing (2) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures wait setup time t wts 19 ns 19.10, 19.15, 19.19 wait hold time t wth 10 ns read data access time 1 *6 t acc1 t cyc ?30* 4 ns 19.8, 19.11, 19.12 read data access time 2 *6 t acc2 t cyc (n+2) 30 *3 ns 19.9, 19.10, 19.13, 19.14 ras delay time 1 t rasd1 25 ns 19.11?9.14, ras delay time 2 t rasd2 ?5ns 19.16?9.18 cas delay time 1 t casd1 25 ns 19.11 cas delay time 2 t casd2 25 ns 19.13, 19.14, cas delay time 3 t casd3 ?5ns 19.16?9.18 column address setup time t asc 0 ns 19.11, 19.12 read data access time from cas 1 *6 35% duty *2 t cac1 t cyc 0.65 19 ?s 50% duty t cyc 0.5 ?19 ns read data access time from cas 2 *6 t cac2 t cyc (n + 1) 25 *3 ns 19.13, 19.14, 19.15 read data access time from ras 1 *6 t rac1 t cyc 1.5 ?20 ns 19.11, 19.12 read data access time from ras 2 *6 t rac2 t cyc (n + 2.5) ?20 *3 ns 19.13, 19.14, 19.15 high-speed page mode cas precharge time t cp t cyc 0.25 ns 19.12 ah delay time 1 t ahd1 25 ns 19.19 ah delay time 2 t ahd2 ?5ns multiplexed address delay time t mad ?0ns multiplexed address hold time t mah 0ns
hitachi 460 table 19.7 bus timing (2) (cont) conditions: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures dack0, dack1 delay time 1 t dacd1 25 ns 19.8, 19.9, 19.11?9.14, dack0, dack1 delay time 2 t dacd2 ?5 ns 19.19, 19.20 dack0, dack1 delay time 3 t dacd3 25 ns 19.9, 19.13, 19.14, 19.19 dack0, dack1 delay time 4 t dacd4 25 ns 19.11, 19.12 dack0, dack1 delay time 5 t dacd5 ?5 ns read delay 35% duty *2 t rdd ? cyc 0.35 + 12 ns 19.8, 19.9, 19.11-19.15, time 50% duty t cyc 0.5 + 15 ns 19.19 data setup time for cas t ds 0 *5 ns 19.11, 19.13 cas setup time for ras t csr 10 ns 19.16, 19.17, 19.18 row address hold time t rah 10 ns 19.11, 19.13 write command hold time t wch 15 ns write command 35% duty *2 t wcs 0 ns 19.11 setup time 50% duty 0 ns access time from cas precharge *6 t acp t cyc - 20 ns 19.12 notes 1. hbs and lbs signals are 30 ns. 2. when frequency is 10 mhz or more 3. n is the number of wait cycles. 4. access time from addresses a0 to a21 is tcyc-25. 5. ? ns for parity output of dram long-pitch access 6. it is not necessary to meet the t rds specification as long as the access time specification is met.
hitachi 461 ck a21?0 hbs , lbs csn dack0 rd (read) dack1 ad15?d0 dph, dpl (read) t 1 t ad t csd1 t csd2 t rsd t rdac1 * 1 t acc1 * 2 t rds t rdh * 3 t dacd1 t dacd2 t rdd notes: 1. for t rdac1 , use t cyc 0.65 ?20 (for 35% duty) or t cyc 0.5 ?20 (for 50% duty) instead of t cyc ?t rdd ?t rds . 2. for t acc1 , use t cyc ?30 instead of t cyc ?t ad (or t csd1 ) ?t rds . 3. t rdh is measured from a21?0, csn , or rd , whichever is negated first. figure 19.8 basic bus cycle: one-state access
hitachi 462 t 1 t 2 t ad t rdd t csd2 t rsd t rdac2 * 1 t acc2 * 2 t rds t rdh * 3 t dacd2 t dacd1 t wsd2 t wsd1 t dacd3 t dacd3 t wdh t wdd1 t wpdh t wpdd1 ck a21?0 hbs , lbs csn dack0 dack1 (read) rd (read) wrh , wrl , wr (write) ad15?d0 dph, dpl (read) ad15?d0 (write) dph, dpl (write) dack0 dack1 (write) t csd1 notes: 1 for t rdac2 , use t cyc (n + 1.65) ?20 (for 35% duty) or t cyc (n + 1.5) ?20 (for 50% duty) instead of t cyc (n + 2) ?t rdd ?t rds . 2 for t acc2 , use t cyc (n + 2) ?30 instead of t cyc (n + 2) ?t ad (or t csd1 ) ?t rds . 3t rdh is measured from a21?0, csn , or rd , whichever is negated first. figure 19.9 basic bus cycle: two-state access
hitachi 463 dack0 dack1 (read) rd (read) csn ad15?d0 dph, dpl (read) a21?0 hbs , lbs dack0 dack1 (write) ck wait ad15?d0 dph, dpl (write) wrh , wrl , wr (write) t 1 t w t 2 t wts t wth t wts t wth t rdac2 * 1 t acc2 * 2 notes: 1. for t rdac2 , use t cyc (n + 1.65) ?20 (for 35% duty) or t cyc (n + 1.5) ?20 (for 50% duty) instead of t cyc (n + 2) ?t rdd ?t rds . 2. for t acc2 , use t cyc (n + 2) ?30 instead of t cyc (n + 2) ?t ad (or t csd1 ) ?t rds . figure 19.10 basic bus cycle: two states + wait state
hitachi 464 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) dph, dpl (write) dack0 dack1 (write) t p t r t c t ad t ad t rasd1 t rasd2 t casd1 t dacd1 t cac1 * 1 t rds t rdh * 4 t wsd3 t wdd2 t wdh t wpdd2 t wpdh t dacd4 t dacd5 t acc1 * 2 t rah t dacd2 t wsd4 t wch t asc t ds row column t wcs t rac1 * 3 rd (write) rd (read) t rsd t rdd notes: 1. for t cac1 , use t cyc 0.65 ?19 (for 35% duty) or t cyc 0.5 ?19 (for 50% duty) instead of t cyc ?t ad ?t asc ?t rds . 2. for t acc1 , use t cyc ?30 instead of t cyc ?t ad ?t rds . 3. for t rac1 , use t cyc 1.5 ?20 instead of t cyc 1.5 ?t rasd1 ?t rds . 4. t rdh is measured from a21?0, ras , or cas , whichever is negated first. figure 19.11 dram bus cycle (short pitch, normal mode)
hitachi 465 ck a21?0 ras cas wrh, wrl , wr (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) t ad t p t r t c t c t c t ad t rasd1 t rasd2 t cp t asc t rdh * 5 t rac1 * 3 t dacd1 t dacd2 column address column address column address t cac1 * 1 t c t acc1 * 2 t rds rd(read) t rdd t acp t rsd t rdh * 4 row address column address notes: 1. for t cac1 , use t cyc 0.65 ?19 (for 35% duty) or t cyc 0.5 ?19 (for 50% duty) instead of t cyc ?t ad ?t asc ?t rds . it is not necessary to meet the t rds specification as long as the t cac1 specification is met. 2. for t acc1 , use t cyc ?30 instead of t cyc ?t ad ?t rds . it is not necessary to meet the t rds specification as long as the t acc1 specification is met. 3. for t rac1 , use t cyc 1.5 ?20 instead of t cyc 1.5 ?t rasd1 ?t rds . it is not necessary to meet the t rds specification as long as the t rac1 specification is met. 4. t rdh is measured from a21?0 or cas , whichever is negated first. 5. t rdh is measured from a21?0, ra s, or cas , whichever is negated first. figure 19.12 (a) dram bus cycle (short-pitch, high-speed page mode: read)
hitachi 466 ck a21?0 ras cas wrh, wrl , wr (write) dack0 dack1 (write) ad15?d0 dph, dpl (write) dph, dpl (write) t ad t p t r t c silent cycle t c t ad t rasd1 t rasd2 t asc t dacd4 t dacd5 t dacd5 rd (write) t wsd4 t wsd3 t wdd2 t wdh t wpdd2 t wpdh column address column address row address figure 19.12 (b) dram bus cycle (short-pitch, high-speed page mode: write) note: for details of the silent cycle, see section 8.5.5, burst operation.
hitachi 467 ck a21?0 ras cas wrh, wrl, (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh, wrl, (write) ad15?d0 (write) t ad t p t r t c1 t c2 t ad t rasd1 t rasd2 dack0 dack1 (write) dph, dpl (write) column t casd3 t acc2* 2 t rdh * 4 t dacd1 t dacd2 t wsd1 t wsd2 t wdd1 t wdh t wpdh t wpdd1 t dacd3 t dacd3 t rac2* 3 t ds t casd2 t wch t cac2 * 1 rd(write) rd(read) t rdd t rsd row t rah t rds notes: 1. for t cac2 , use t cyc (n + 1) ?25 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?30 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?20 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . 4. t rdh is measured from a21?0, cas , or ras , whichever is negated first. figure 19.13 dram bus cycle: (long pitch, normal mode)
hitachi 468 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) dack0 dack1 (write) dph, dpl (write) t p t r t c1 t c2 t c1 t c2 t ad t ad t rasd1 t rasd2 t casd3 t casd2 t rdh * 5 t casd3 t rdh * 4 t rac2 * 3 t acc2 * 2 t cac2 * 1 t rds t dacd1 t dacd1 t dacd2 t dacd2 t wsd1 t wsd1 t wsd2 t wsd2 t wdd1 t wdh t wdd1 t wdh t wpdd1 t wpdd1 t wpdh t wpdh t dacd3 t dacd3 t dacd3 t dacd3 column column rd (write) rd (read) t rdd t rsd row notes: 1. for t cac2 , use t cyc (n + 1) ?25 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?30 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?20 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . 4. t rdh is measured from a21?0 or cas , whichever is negated first. 5. t rdh is measured from a21?0, ras , or cas whichever is negated first. figure 19.14 dram bus cycle: (long pitch, high-speed page mode)
hitachi 469 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) dack0 dack1 (write) dph, dpl (write) wait t p t r t c1 t w t c2 row column t wts t wth t wts t wth t acc2 * 2 t rac2 * 3 t cac2 * 1 rd (write) rd (read) t rsd t rdd notes: 1. for t cac2 , use t cyc (n + 1) ?25 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?30 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?20 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . figure 19.15 dram bus cycle: (long pitch, high-speed page mode + wait state)
hitachi 470 ck ras cas wrh , wrl t rp t rr t rc t rasd1 t rasd2 t casd3 t casd2 t csr figure 19.16 cas-before-ras refresh (short pitch) ck ras cas wrh , wrl t rp t rc t rc t rasd1 t rasd2 t casd3 t casd2 t rr t csr figure 19.17 cas-before-ras refresh (long pitch)
hitachi 471 ck ras cas t rp t rc t rcc t rasd1 t rasd2 t casd3 t casd2 t rr t csr figure 19.18 self refresh
hitachi 472 ck a21?0 hbs , lbs cs6 ah rd (read) dack0 dack1 (read) ad15?d0 (read) wrh , wrl , wr (write) ad15?d0 (write) dack0 dack1 (write) wait t 1 t 2 t 3 t 4 t csd4 t csd3 t ad t ahd1 t ahd2 t rsd t rdh t mah t mad t rdac3 t dacd2 t dacd1 t wsd1 t wsd2 t mad t mah t wdd1 t dacd3 t dacd3 t wth t wts address address data (output) t rdd t wdh data (input) figure 19.19 address/data multiplex i/o bus cycle
hitachi 473 ck a21?0 hbs , lbs csn dack0 dack1 (write) wrh , wrl , wr (write) t 1 t ad t csd1 t csd2 t wsd4 t dacd1 t dacd2 t wsd1 figure 19.20 dma single transfer/1 state access write
hitachi 474 table 19.8 bus timing (3) conditions: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures address delay time t ad 40 ns 19.21, 19.22, 19.24 19.27, 19.32, 19.33 cs delay time 1 t csd1 40 ns 19.21, 19.22, 19.33 cs delay time 2 t csd2 ?0ns cs delay time 3 t csd3 40 ns 19.32 cs delay time 4 t csd4 ?0ns access time 1 *4 35% duty *1 t rdac1 t cyc 0.65 ?35 ns 19.21, from read strobe 50% duty t cyc 0.5 ?35 ns access time 2 *4 35% duty *1 t rdac2 t cyc (n+1.65) ?35 *2 ns 19.22, 19.23 from read strobe 50% duty t cyc (n+1.5) ?35 *2 ?s access time 3 *4 35% duty *1 t rdac3 t cyc (n+0.65) ?35 *2 ns 19.32 from read strobe 50% duty t cyc (n+0.5) ?35 *2 ?s read strobe delay time t rsd 40 ns 19.21, 19.22, 19.32 read data set-up time t rds 30 ns 19.21, 19.22, read data hold time t rdh 0 ns 19.24-19.27, 19.32 write strobe delay time 1 t wsd1 40 ns 19.22, 19.26, 19.27, 19.32, 19.33 write strobe delay time 2 t wsd2 30 ns 19.22, 19.26, 19.27, 19.32 write strobe delay time 3 t wsd3 40 ns 19.24, 19.25 write strobe delay time 4 t wsd4 40 ns 19.24, 19.25, 19.33 write data delay time 1 t wdd1 70 ns 19.22, 19.26, 19.27, 19.32 write data delay time 2 t wdd2 40 ns 19.24, 19.25 write data hold time t wdh ?0 ns 19.22, 19.24?9.27, 19.32 parity output delay time 1 t wpdd1 80 ns 19.22, 19.24, 19.27 parity output delay time 2 t wpdd2 40 ns 19.24, 19.25 parity output hold time t wpdh ?0 ns 19.22, 19.24?9.27
hitachi 475 table 19.8 bus timing (3) (cont) conditions: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. item symbol min max unit figures wait setup time t wts 40 ns 19.23, 19.28, 19.32 wait hold time t wth 10 ns read data access time 1 *4 t acc1 t cyc ?44 ns 19.21, 19.24, 19.25 read data access time 2 *4 t acc2 t cyc (n+2) ?44 *2 ns 19.22, 19.23, 19.26, 19.28 ras delay time 1 t rasd1 40 ns 19.24?9.27, 19.29 ras delay time 2 t rasd2 ?0ns 19.31 cas delay time 1 t casd1 40 ns 19.24 cas delay time 2 t casd2 40 ns 19.26, 19.27, 19.29 cas delay time 3 t casd3 ?0ns 19.31 column address setup time t asc 0 ns 19.24, 19.25 read data 35% duty *1 t cac1 t cyc 0.65 ?35 ns access time from cas 1 *4 50% duty t cyc 0.5 ?35 ns read data access time from cas 2 *4 t cac2 t cyc (n+1) ?35 *2 ns 19.26, 19.27, 19.28 read data access time from ras 1 *4 t rac1 t cyc 1.5 ?35 ns 19.24, 19.25 read data access time from ras 2 *4 t rac2 t cyc (n+2.5) ?35 *2 ns 19.26, 19.27, 19.28 high-speed page mode cas precharge time t cp t cyc 0.25 ns 19.25 ah delay time 1 t ahd1 40 ns 19.32 ah delay time 2 t ahd2 ?0ns multiplexed address delay time t mad ?0ns multiplexed address hold time t mah ?0 ns
hitachi 476 table 19.8 bus timing (3) (cont) conditions: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products item symbol min max unit figures dack0, dack1 delay time 1 t dacd1 40 ns 19.21, 19.22, 19.24 dack0, dack1 delay time 2 t dacd2 ?0 ns 19.27, 19.32, 19.33 dack0, dack1 delay time 3 t dacd3 40 ns 19.22, 19.26, 19.27, 19.32 dack0, dack1 delay time 4 t dacd4 40 ns 19.24, 19.25 dack0, dack1 delay time 5 t dacd5 ?0 ns read delay time 35% duty *1 t rdd ? cyc 0.35 + 35 ns 19.21, 19.22, 19.24- 50% duty t cyc 0.5 + 35 ns 19.28, 19.32 data setup time for cas t ds 0* 3 ns 19.24, 19.26 cas setup time for ras t csr 10 ns 19.29?9.31 row address hold time t rah 10 ns 19.24, 19.26 write command hold time t wch 15 ns write command 35% duty *1 t wcs 0 ns 19.24 setup time 50% duty t wcs 0 ns access time from cas precharge *4 t acp tcyc -20 ns 19.25 notes: 1. when frequency is 10 mhz or more. 2. n is the number of wait cycles. 3. ? ns for parity output of dram long-pitch access 4. it is not necessary to meet the t rds specification as long as the access time specification is met.
hitachi 477 ck a21?0 hbs , lbs csn dack0 rd (read) dack1 ad15?d0 dph, dpl (read) t 1 t ad t csd1 t csd2 t rsd t rdac1 * 1 t acc1 * 2 t rds t rdh * 3 t dacd1 t dacd2 t rdd notes: 1. for t rdac1 , use t cyc 0.65 ?35 (for 35% duty) or t cyc 0.5 ?35 (for 50% duty) instead of t cyc ?t rdd ?t rds . 2. for t acc1 , use t cyc ?44 instead of t cyc ?t ad (or t csd1 ) ?t rds . 3. t rdh is measured from a21?0, csn , or rd , whichever is negated first. figure 19.21 basic bus cycle: one-state access
hitachi 478 t 1 t 2 t ad t rdd t csd2 t rsd t rdac2 * 1 t acc2 * 2 t rds t rdh * 3 t dacd2 t dacd1 t wsd2 t wsd1 t dacd3 t dacd3 t wdh t wdd1 t wpdh t wpdd1 ck a21?0 hbs , lbs csn dack0 dack1 (read) rd (read) wrh , wrl , wr (write) ad15?d0 dph, dpl (read) ad15?d0 (write) dph, dpl (write) dack0 dack1 (write) t csd1 notes: 1. for t rdac2 , use t cyc (n + 1.65) ?35 (for 35% duty) or t cyc (n + 1.5) ?35 (for 50% duty) instead of t cyc (n + 2) ?t rdd ?t rds . 2. for t acc2 , use t cyc (n + 2) ?44 instead of t cyc (n + 2) ?t ad (or t csd1 ) ?t rds . 3. t rdh is measured from a21?0, csn , or rd , whichever is negated first. figure 19.22 basic bus cycle: two-state access
hitachi 479 dack0 dack1 (read) rd (read) csn ad15?d0 dph, dpl (read) a21?0 hbs , lbs dack0 dack1 (write) ck wait ad15?d0 dph, dpl (write) wrh , wrl , wr (write) t 1 t w t 2 t wts t wth t wts t wth t rdac2 * 1 t acc2 * 2 notes: 1. for t rdac2 , use t cyc (n + 1.65) ?35 (for 35% duty) or t cyc (n + 1.5) ?35 (for 50% duty) instead of t cyc (n + 2) ?t rdd ?t rds . 2. for t acc2 , use t cyc (n + 2) ?44 instead of t cyc (n + 2) ?t ad (or t csd1 ) ?t rds . figure 19.23 basic bus cycle: two states + wait state
hitachi 480 ck a21?0 ras cas wrh, wrl, (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh, wrl, (write) ad15?d0 (write) dph, dpl (write) dack0 dack1 (write) t p t r t c t ad t ad t rasd1 t rasd2 t casd1 t dacd1 t cac1 * 1 t rac1 * 3 t rdh * 4 t wsd3 t wsd4 t wdd2 t wdh t wpdd2 t wpdh t dacd4 t dacd5 t acc1 * 2 t rah t wcs row column t asc t ds t dacd2 t rds rd(write) rd(read) t rsd t rdd t wch notes: 1. for t cac1 , use t cyc 0.65 ?35 (for 35% duty) or t cyc 0.5 ?35 (for 50% duty) instead of t cyc ?t ad ?t asc ?t rds . 2. for t acc1 , use t cyc ?44 instead of t cyc ?t ad ?t rds . 3. for t rac1 , use t cyc 1.5 ?35 instead of t cyc 1.5 ?t rasd1 ?t rds . 4. t rdh is measured from a21?0, ras , or cas , whichever is negated first. figure 19.24 dram bus cycle (short pitch, normal mode)
hitachi 481 ck a21?0 ras cas wrh, wrl , wr (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) t ad t p t r t c t c t c t ad t rasd1 t rasd2 t cp t asc t rdh * 5 t rac1 * 3 t dacd1 t dacd2 row address column address column address column address t cac1 * 1 t c t acc1 * 2 t rds rd(read) t rdd t acp t rsd t rdh * 4 column address notes: 1. for t cac1 , use t cyc 0.65 ?35 (for 35% duty) or t cyc 0.5 ?35 (for 50% duty) instead of t cyc ?t ad ?t asc ?t rds . it is not necessary to meet the t rds specification as long as the t cac1 specification is met. 2. for t acc1 , use t cyc ?44 instead of t cyc ?t ad ?t rds . it is not necessary to meet the t rds specification as long as the t acc1 specification is met. 3. for t rac1 , use t cyc 1.5 ?35 instead of t cyc 1.5 ?t rasd1 ?t rds . it is not necessary to meet the t rds specification as long as the t rac1 specification is met. 4. t rdh is measured from a21?0 or cas , whichever is negated first. 5. t rdh is measured from a21?0, ras , or cas , whichever is negated first. figure 19.25 (a) dram bus cycle (short-pitch, high-speed page mode: read)
hitachi 482 ck a21?0 ras cas wrh, wrl , wr (write) dack0 dack1 (write) ad15?d0 dph, dpl (write) dph, dpl (write) t ad t p t r t c silent cycle t c t ad t rasd1 t rasd2 t asc t dacd4 t dacd5 t dacd5 row address column address column address rd (write) t wsd4 t wsd3 t wdd2 t wdh t wpdd2 t wpdh figure 19.25 (b) dram bus cycle (short-pitch, high-speed page mode: write) note: for details of the silent cycle, see section 8.5.5, burst operation.
hitachi 483 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) t ad t p t r tc 1 tc 2 t ad t rasd1 t rasd2 dack0 dack1 (write) dph, dpl (write) column t casd3 t rdh * 4 t rds t dacd1 t dacd2 t wsd1 t wsd2 t wdd1 t wdh t wpdh t wpdd1 t dacd3 t dacd3 t rah t acc2* 2 t rac2* 3 t casd2 t ds t cac2* 1 t wch rd (write) rd (read) t rdd t rds row notes: 1. for t cac2 , use t cyc (n + 1) ?35 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?44 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?35 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . 4. t rdh is measured from a21?0, cas , or ras , whichever is negated first. figure 19.26 dram bus cycle: (long pitch, normal mode)
hitachi 484 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) dack0 dack1 (write) dph, dpl (write) t p t r t c1 t c2 t c1 t c2 t ad t ad t rasd2 t casd3 t casd2 t rdh * 5 t casd3 t rdh * 4 t rac2 * 3 t acc2 * 2 t cac2 * 1 t rds t dacd1 t dacd1 t dacd2 t dacd2 t wsd1 t wsd1 t wsd2 t wsd2 t wdd1 t wdh t wdd1 t wdh t wpdd1 t wpdd1 t wpdh t wpdh t dacd3 t dacd3 t dacd3 t dacd3 column column rd (write) rd (read) t rdd t rasd1 row t rsd notes: 1. for t cac2 , use t cyc (n + 1) ?35 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?44 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?35 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . 4. t rdh is measured from a21?0 or cas , whichever is negated first. 5. t rdh is measured from a21?0, ras , or cas whichever is negated first. figure 19.27 dram bus cycle: (long pitch, high-speed page mode)
hitachi 485 ck a21?0 ras cas wrh , wrl , (read) dack0 dack1 (read) ad15?d0 dph, dpl (read) wrh , wrl , (write) ad15?d0 (write) dack0 dack1 (write) dph, dpl (write) wait t p t r t c1 t w t c2 row column t wts t wth t wts t wth t rac2 * 3 t acc2 * 2 t cac2 * 1 rd (write) rd (read) t rds t rdd notes: 1. for t cac2 , use t cyc (n + 1) ?35 instead of t cyc (n + 1) ?t casd2 ?t rds . 2. for t acc2 , use t cyc (n + 2) ?44 instead of t cyc (n + 2) ?t ad ?t rds . 3. for t rac2 , use t cyc (n + 2.5) ?35 instead of t cyc (n + 2.5) ?t rasd1 ?t rds . figure 19.28 dram bus cycle: (long pitch, high-speed page mode + wait state)
hitachi 486 ck ras cas wrh , wrl t rp t rr t rc t rasd1 t rasd2 t casd3 t casd2 t csr figure 19.29 cas-before-ras refresh (short pitch) ck ras cas wrh , wrl t rp t rc t rc t rasd1 t rasd2 t casd3 t casd2 t rr t csr figure 19.30 cas-before-ras refresh (long pitch)
hitachi 487 ck ras cas t rp t rc t rcc t rasd1 t casd3 t casd2 t rr t csr t rasd2 figure 19.31 self refresh
hitachi 488 ck a21?0 hbs , lbs cs6 ah rd (read) dack0 dack1 (read) ad15?d0 (read) wrh , wrl , wr (write) ad15?d0 (write) dack0 dack1 (write) wait t 1 t 2 t 3 t 4 t csd4 t csd3 t ad t ahd1 t ahd2 t rsd t rdh t mah t mad t rdac3 t dacd2 t dacd1 t wsd1 t wsd2 t mad t mah t wdd1 t dacd3 t dacd3 t wth t wts address address data (output) t rdd t wdh data (input) figure 19.32 address/data multiplex i/o bus cycle
hitachi 489 ck a21?0 hbs , lbs csn dack0 dack1 (write) wrh , wrl , wr (write) t 1 t ad t csd1 t csd2 t wsd4 t dacd1 t dacd2 t wsd1 figure 19.33 dma single transfer/single state access write
hitachi 490 19.3.4 dmac timing table 19.9 dmac timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. case a case b 12.5 mhz 16.6 mhz 20 mhz item symbol min max min max min max unit figure dreq0 , dreq1 setup time t drqs 80 40 27 ns 19.34 dreq0 , dreq1 hold time t drqh 30 30 30 ns dreq0 , dreq1 low level width t drqw 1.5 1.5 1.5 t cyc 19.35 t drqs t drqs ck dreq0 , dreq1 level dreq0 , dreq1 edge t drqs t drqh dreq0 , dreq1 level release figure 19.34 dreq0 , dreq 1 input timing (1) ck t drqw dreq0 , dreq1 edge figure 19.35 dreq0 , dreq 1 input timing (2)
hitachi 491 19.3.5 16-bit integrated timer pulse unit timing table 19.10 16-bit integrated timer pulse unit timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. case a case b 12.5 mhz 16.6 mhz 20 mhz item symbol min max min max min max unit figure output compare delay time t tocd 100 100 100 ns 19.36 input capture setup time t tics 50 45 35 ns timer clock input setup time t tcks 50 50 50 ns 19.37 timer clock pulse width (single edge) t tckwh/l 1.5 1.5 1.5 t cyc timer clock pulse width (both edges) t tckwh/l 2.5 2.5 2.5 t cyc t tocd ck t tics output compare* 1 output capture* 2 notes: 1. tioca0?ioca4, tiocb0?iocb4, tocxa4, tocxb4 2. tioca0?ioca4, tiocb0?iocb4 figure 19.36 itu input/output timing
hitachi 492 t tcks ck t tckwh t tckwl t tcks tclka? tclkd figure 19.37 itu clock input timing
hitachi 493 19.3.6 programmable timing pattern controller and i/o port timing table 19.11 programmable timing pattern controller and i/o port timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* case c: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. cases a, b and c item symbol min max unit figure port output delay time t pwd 100 ns 19.38 port input hold time t prh 50 ns port input setup time t prs 50 ns t prs ck t pwd ports a, b (read) ports a, b (write) t 1 t 2 t 3 t prh figure 19.38 programmable timing pattern controller output timing
hitachi 494 19.3.7 watchdog timer timing table 19.12 watchdog timer timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 v, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* case c: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products. ta = ?0 to +85? for wide-temperature range products. cases a, b and c item symbol min max unit figure wdtovf delay time t wovd 100 ns 20.39 t wovd ck t wovd wdtovf figure 19.39 watchdog timer output timing
hitachi 495 19.3.8 serial communications interface timing table 19.13 serial communications interface timing case a: v cc = 3.0 to 5.5 v, v ss = 0 v, f = 12.5 mhz, ta = ?0 to +75?* case b: v cc = 5.0 v ?0%, v ss = 0 v, f = 16.6 mhz, ta = ?0 to +75?* case c: v cc = 5.0 v ?0%, v ss = 0 v, f = 20 mhz, ta = ?0 to +75?* *: normal products: ta = ?0 to +85? for wide-temperature range products. cases a, b and c item symbol min max unit figure input clock cycle t scyc 4t cyc 19.40 input clock cycle (clocked synchronization) t scyc 6t cyc input clock pulse width t sckw 0.4 0.6 t scyc input clock rise time t sckr 1.5 t cyc input clock fall time t sckf 1.5 t cyc transmission data delay time (clocked synchronization) t txd 100 ns 19.41 receive data setup time (clocked synchronization) t rxs 100 ns receive data hold time (clocked synchronization) t rxh 100 ns sck0, sck1 t scyc t sckw t sckr t sckf figure 19.40 input clock timing
hitachi 496 sck0, sck1 t scyc t rxs t txd t rxh txd0, txd1 (transmission data) rxd0, rxd1 (reception data) figure 19.41 sci i/o timing (clocked synchronization mode)
hitachi 497 19.3.9 ac characteristics measurement conditions v v ref i oh c l device under test output lsi output pin i ol c l is set as follows for each pin. 30pf: ck, cash , casl , cs0 cs7 , breq , back , ah , irqout , ras , dack0, dack1 50pf: a21?0, ad15?d0, dph, dpl, rd , wrh , wrl , hbs , lbs , wr 70pf: all port outputs and peripheral module output pins other than the above. i ol and i oh values are as shown in section 19.2, dc characteristics, and table 19.3, permitted output current values. figure 19.42 output load circuit
hitachi 498 19.4 usage note the ztat version and the mask rom version satisfy the electrical properties given in this document. however, effective values of the electrical properties, the operating margin, and the noise margin may differ with the manufacturing processes, on-chip rom, and layout patterns. when conducting a system evaluation test using the ztat version, conduct a similar evaluation test of the mask rom version before it replaces the ztat version.
sh7020, sh7021 hardware manual publication date: 1st edition, september 1994 3rd edition, september 1998 published by: electronic devices sales & marketing group semiconductor & integrated circuits group hitachi, ltd. edited by: technical documentation group ul media co., ltd. co py ri g ht hitachi, ltd., 1994. all ri g hts reserved. printed in ja p an.


▲Up To Search▲   

 
Price & Availability of HD6437021TE

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X